您的位置:首页 > 其它

UVa 10815 - Andy's First Dictionary

2013-04-11 17:17 363 查看
#include <iostream>
#include <cstdio>
#include <cctype>
#include <set>
#include <string>

using namespace std;

char buff[220];
int k_num = 0;

int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
typedef set<string, less<string> > myset;
myset s;
myset::iterator itr;

char *p;
bool found;
int l;
char word[20];
while(fgets(buff, sizeof(buff), stdin)) {
p = buff;
found = false;
l = 0;
while(*p || found) {
if(isalpha(*p)) {
found = true;
word[l++] = tolower(*p);
} else if(found) {
found = false;
word[l] = 0;
s.insert(word);
l = 0;
}
p++;
}
}
for(itr=s.begin(); itr!=s.end(); itr++)
cout << *itr << endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: