您的位置:首页 > 其它

uva 10815 Andy's First Dictionary

2011-09-19 23:20 357 查看
题意:给你数个字符串,要你把字符串中的所以出现单词,不重复的按字典序输出。
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <cstring>
using namespace std;
int main()
{
char word[1000];
set<string> adj;
while(gets(word))
{
string key="";
int len=strlen(word);

for(int i=0;i<len;i++)
{
if(isalpha(word[i]))
{
key+=tolower(word[i]);
}
else
{
if(key!="") adj.insert(key);
key="";
}
}
if(key!="") adj.insert(key);
}
set<string>::iterator it;
for(it=adj.begin();it!=adj.end();it++) printf("%s\n",(*it).c_str());
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: