注册 登录
编程论坛 VC++/MFC

求助,这个程序如何修改

hold住哥 发布于 2011-09-05 22:39, 270 次点击
#include<iostream>
#include<list>
#include<string>
#include<cstdlib>
using namespace std;

int main()
{
    list<string>lst;

    string c;
    int i;
    for(i=0;i<10;i++)
    {
        cout<<"please input "<<i+1<<"student's name"<<endl; //输入数干个学生名字
        cin>>c;
        lst.push_back(c); //插入列表
    }
    cout<<"no arrange";

    list<string>::iterator p=lst.begin();//迭代器

    while(p!=lst.end())
    {
        cout<<*p<<endl;//输出没排序的列表
        P++;
    }
    cout<<endl;

    lst.sort(); //排序
    cout<<"after arrange";
    p=lst.begin();
   
    while(p!=lst.end())
    {
        cout<<*p<<endl;//输出排序后的列表
        p++;
    }
    return 0;
}
如何定义p,求修改
2 回复
#2
czsbc2011-09-05 22:41
把大写的P改为小写p
#3
hold住哥2011-09-05 23:08
回复 2楼 czsbc
我真大意,还是旁观者清
1