问题:
解答:
#include <iostream>
#include <cstring>
using namespace std;#define SIZE 20int main()
{string words[SIZE];string done = "done";int count = 0;while (true){cout << "请输入单词:" << endl;cin >> words[count++];if (words[count - 1] == done){count--;break;}cin.get();}cout << "在done前一共输入了" << count << "哥单词" << endl;return 0;
}
运行结果:
考查点:
- string的字符串比较
注意:
我走了用了数组保存,不用直接计数也可以.
2024年8月25日20:47:14