UVa10815 Andy's First Dictionary

Description

自己看

Algorithm

主要是学习了一下
set和stringstream的用法

Code

#include <iostream>
#include <set>
#include <sstream>
using namespace std;
set<string> dict;
int main()
{
  string s;
  while (cin >> s)
  {
    for (int i = 0; i < s.size(); i++)
      if (isalpha(s[i])) s[i] = tolower(s[i]); else s[i] = ' ';
    stringstream ss(s);
    string buff;
    while (ss >> buff) dict.insert(buff);
  }
  for (set<string>::iterator it = dict.begin(); it != dict.end(); it++)
    cout << *it << endl;
}

你可能感兴趣的:(UVa10815 Andy's First Dictionary)