转载的老师发的答案,关注我,随时更新答案,如果来不及了,可以私信我,我发给你们相应的答案
#include <iostream>
using namespace std;
int main()
{
int counter{1};
bool exit{false};
while (!exit)
{
std::cout << counter << " ";
++counter;
exit = (counter == 5);
}
cout << endl << "Broke out of loop at count = " << counter << endl;
return 0;
}
下面是运行结果: