2.3.3 `do while`循环

大纲目录

文章目录


do while循环

#include <iostream>

int main()
{
	using namespace std;

	cout << "请输入一个数字:\n";
	int n;

	do
	{
		cin >> n;
	} while (n != 7);

	cout << "输入正确" << endl;

	return 0;
}

2.3.3 `do while`循环


// [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++;
}
上一篇:something just like this


下一篇:tensorflow + GradientDescentOptimizer 拟合直线