#include <iostream> using namespace std; int main(void) { string word; int wordcount = 0; int length = 0; cout << "请输入若干个单词:" << endl; while (1) { if (!(cin >> word)) { break; } wordcount++; length += word.length(); } cout << "单词的个数是:" << wordcount << endl; cout << "单词的总长度是:" << length << endl; system("pause"); return 0; }