UVA10815 Andy's First Dictionary

简单题

#include<iostream>
#include<string>
#include<set>
#include<cctype>
using namespace std;

int main(){
	

	string s;
	set<string> data;
	while (cin >> s){
		string::size_type i = 0;
		string s2;
		int len = s.length();
		for (; i < len; i++){

			if (isalpha(s[i])){
				s[i] = tolower(s[i]);
				s2 += s[i];
				
			}
			else{

				string s3 = s2;
				if (!s3.empty()){
					data.insert(s3);
					int x = data.size();
				}
				s2 = "";
			}
			if (isalpha(s[i])&&(i == len - 1)){
				string s3 = s2;
				if (!s3.empty()){
					data.insert(s3);
				
				}
				s2 = "";
			
			}
			
			
			
			
			
		
		}
	
	
	
	}
	set<string>::iterator j;
	for (j = data.begin(); j != data.end(); j++){
		cout << *j << endl;
	
	}




	return 0;
}


你可能感兴趣的:(uva)