1 条题解
-
0
#include #include using namespace std; int main() { string s, tmp, max_word, min_word; getline(cin, s);
int max_len = 0, min_len = 101; bool in_word = false; for (char c : s) { if (isalpha(c)) { tmp += c; in_word = true; } else { if (in_word) { if (tmp.size() > max_len || max_word.empty()) { max_len = tmp.size(); max_word = tmp; } if (tmp.size() < min_len || min_word.empty()) { min_len = tmp.size(); min_word = tmp; } tmp.clear(); } in_word = false; } } if (!tmp.empty()) { if (tmp.size() > max_len) max_word = tmp; if (tmp.size() < min_len) min_word = tmp; } cout << max_word << endl << min_word << endl; return 0;}
- 1
信息
- ID
- 147
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- 递交数
- 24
- 已通过
- 12
- 上传者