UVA 10815 set

UVA 10815 set

#include<iostream>
#include<string>
#include<set>
#include<sstream>

using namespace std;

set<string> dict;
string s, buf;

int main() 
{
    while(cin >> s) //???这里需要Ctrl+Z结束输入
    {
        for(int i = 0; i < s.length(); i++)
        {
            if(isalpha(s[i])) //判断是否为字母,区别标点符号
                s[i] = tolower(s[i]); 
            else s[i] = ' ';//将标点符号变成空格,从而接下来删除它们
        }  

        stringstream ss(s);
        while(ss >> buf) 
            dict.insert(buf);
    }
    for(set<string>::iterator it = dict.begin(); it != dict.end(); ++it)、
        cout << *it << "
";//这里需要迭代器进行遍历,而不是i
    return 0;
}
透过泪水看到希望
原文地址:https://www.cnblogs.com/ronnielee/p/9495144.html