// [7/23/2014 Sjm] /* 细节考察: WA了几次。。。由于空格可以被 getline 读入,所以增加判断条件。。。 测试用例: ab (注意ab前有一个空格) 输出: 1 */#include <iostream> #include <cstdlib> #include <cstdio> #include <string> #include <set> using namespace std; bool Judge(char ch) { if (ch >= 'a' && ch <= 'z') { return true; } return false; } int main() { //freopen("input.txt", "r", stdin); string str; while (getline(cin, str) && str != "#") { str += "."; string t_str; set<string> myset; for (int i = 0; i < str.size(); ++i) { if (Judge(str[i])) { t_str += str[i]; }else { if (t_str.size()) { // 此处增加判断条件 myset.insert(t_str); } t_str = ""; } } cout << myset.size() << endl; myset.clear(); } return 0; }
水题(细节考察getline) 之 hdu 2072
最新推荐文章于 2020-04-15 23:29:35 发布