【題解】UVA-10815 Andy’s First Dictionary

【題目敘述】https://vjudge.net/problem/UVA-10815
【解題想法】set
【注意】所有的非字母符號都視為分隔符號

#include <iostream>
#include <sstream>
#include <set>
using namespace std;

int main() {
	string s, t;
	set <string> st;
	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);
		while (ss >> s) {
			st.insert(s);
		}
	}
	for (auto x: st) {
		cout << x << "\n";
	}
    return 0;
}
分享本文 Share with friends