统计单词数量(C++)

it2024-07-17  39

代码(C++)

只输入空格和单词,回车结束

#include <iostream> #include <vector> #include <string> using namespace std; int main() { vector<string> s; string temp; while (cin >> temp) { s.push_back(temp); if (cin.get() == '\n') { break; } } cout << s.size() << endl; return 0; }
最新回复(0)