1、do while 循环
do
body
whil (test-expression);
2、通常入口条件比出口条件好,因为入口条件会在循环开始之前对条件进行检查。但有时候do while更合理,例如请求用户输入时,必须先获得输入再进行测试。
3、例子:
#include <iostream>
int main()
{
using namespace std;
int n;
cout << "Enter numbers in the range 1-10 to find ";
cout << "my favorite umber\n";
do
{
cin >> n;
}while (n != 7);
cout << "Yes, 7 is my favorite.\n";
cin.get();
return 0;
}