问题:
解答:
#include <iostream>
#include <cstring>
using namespace std;
#define SIZE 20
int 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





![[ICLR-24] LRM: Large Reconstruction Model for Single Image to 3D](https://i-blog.csdnimg.cn/direct/40b6734cf76d4b46a00ac130061fec0c.png)
![[C++] 初识 智能指针](https://i-blog.csdnimg.cn/direct/57a7acb425fc43e48f098c1c7cfa4b3b.jpeg)












