// 66节项目练习一 2020.2.8.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//连续输入多个单词,然后统计这些单词总的长度,以及单词个数
#include
#include
#include
using namespace std;
int main(void) {
string word;//单词
int count=0; //计数
int length=0; //长度
cout << "请连续输入多个单词:" << endl;
while (1) {
if ((cin >> word) == 0) {
break;
}
cin >> word;
count++;
length += word.length();
}
cout << "一共有" << count << "个单词" << endl;
cout << "总长度是:" << length << endl;
system("pause");
return 0;
}