文章目录
do while
循环
#include <iostream>
int main()
{
using namespace std;
cout << "请输入一个数字:\n";
int n;
do
{
cin >> n;
} while (n != 7);
cout << "输入正确" << endl;
return 0;
}
// [1]
int i = 0;
for (;;)
{
i++;
// do something
if (30 >= i)
{
break;
}
}
// [2]
int i = 0;
for (;; i++)
{
if (30 >= i)
{
break;
}
// do something
}
// [1']
int i = 0;
do
{
i++;
// do something
} (while 30 >= i)
// [2']
int i = 0;
while (30 >= i)
{
// do something
i++;
}