#include<stdio.h>
int main() {
/*___________________while循环____________________*/
int count = 0;
//1.while循环
/*
while(count < 10) {
printf("Hello World\n");
//这句话得写上,不然是死循环
// count = count + 1;
count ++;
}
*/
//后面的{}如果省略了,则while后面的第一句话是while循环语句
// while(count < 10)
// printf("Hello World\n");
// count ++;
//注意点一:
//while的语句和后面的语句没有任何关系
// while(count < 10); //错误
{
// printf("Hello World\n");
count ++;
}
//2.do...while循环
//先执行、后判断
int count2 = 0;
do {
//循环体
printf("Hello World\n");
}while(count2 > 10); //注意此处的分号
return 0;
}
do- while 与while
最新推荐文章于 2023-02-22 22:36:43 发布