代码(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;
}