迭代器问题

damotiansheng 2011-11-10 05:19:42
给出n个字符串,请将它们(按字典序)从小到大排序后输出。
(字符串比较规则样例参考:a < abc < bcaa)
请不要使用库函数。
字典序的概念请参照百度百科
http://baike.baidu.com/view/4670107.htm

Input

第一行只有一个正整数n。(n <= 100)
后面n行,每行一串由小写字母组成的字符串(长度不超过100)

Output

输出有n行。
从小到大输出n行字符串。

Sample Input

3
bcaa
a
abc


下面是我的代码

// Note:Your choice is C++ IDE
#include <iostream>
#include<set>
#include<vector>
using namespace std;
int main()
{
set< vector<char> > paixu;
vector<char> charu;
int i,j,n,ct=0;
char c;
cin>>n;
cin.ignore();
while(1)
{

c=cin.get();
if(c!='\n')
charu.push_back(c);
else
{
paixu.insert(charu);
ct++;
if(ct==n) break;
charu.clear();
}
}
vector<char>::iterator ve;
set< vector<char> >::iterator it;
for(it=paixu.begin(); it!=paixu.end(); it++)
{
for(ve=(*it).begin(); ve!=(*it).end(); ve++)
cout<<*ve;
cout<<endl;
}




return 0;
}


for(ve=(*it).begin(); ve!=(*it).end(); ve++)

上面这句编译不过,请问事什么原因呢,各位高手们,
...全文
85 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengzhixi 2011-11-10
  • 打赏
  • 举报
回复
vector<char>::const_iterator ve;
turing-complete 2011-11-10
  • 打赏
  • 举报
回复
VS2008 0警告 0错误

64,637

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧