HDU 2072 单词数

http://acm.hdu.edu.cn/showproblem.php?pid=2072

set以及string的一点应用

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <set>
//#include <map>
#include <queue>
#include <utility>
#include <iomanip>
#include <stack>
#include <list>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
//#include <ctime>
#include <ctype.h>
using namespace std;

int main()
{
	string s;
	char ch;
	set<string> myset;
	while (ch = getchar(), ch != '#')
	{
		s = "";
		s += ch;
		while (ch != '\n')
		{
			while (ch = getchar(), ch != ' ' && ch != '\n')
				s += ch;
			if (s.length())
				myset.insert (s);
			s = "";
		}
		printf ("%d\n", myset.size());
		myset.clear();
	}
	return 0;
}

你可能感兴趣的:(编程,C++,c,ACM,STL)