当需要在每次输入前给提示时,do while循环好于while循环
const int secret_code = 13;
int code_entered;
pritnf("To enter the treskaidekaphobia therapy club,\n");
printf("please enter the secret code number:");
scanf("%d", &code_entered);
while ( code_entered != secret_code )
{
pritnf("To enter the treskaidekaphobia therapy club,\n");
printf("please enter the secret code number:");
scanf("%d", &code_entered);
}
printf("Congratuations! You are cured!\n");
const int secret_code = 13;
int code_entered;
do
{
pritnf("To enter the treskaidekaphobia therapy club,\n");
printf("please enter the secret code number:");
scanf("%d", &code_entered);
} while ( code_entered != secret_code );
printf("Congratuations! You are cured!\n");
标签:do,code,...,printf,secret,while,enter,entered
From: https://www.cnblogs.com/3-141592653589/p/17839802.html