2.11循環語句for

#include <stdio.h>
#include <stdlib.h>
int main()
{
int score;
int cishu;

for(cishu=0;cishu<3;cishu++){

printf("請輸入第%d次成績 \n",cishu+1);
scanf("%d",&score);

if(score>=90)
{
	printf("優秀\n");
}
else if(75<score && score<=90)
{
	printf("良好\n");
}
else if(60<=score && score<=75)
{
	printf("及格\n");
}
else if(40<score && score<60)
{
	printf("不及格\n");
}
else
{
printf("退學\n");
}
if(cishu == 3){
break;
}

}
system(“pause”);
return 0;
}
for(初始條件;當不滿足,不執行;讓條件變化)
while(1) for(;😉//死循環

while(0){}裏面不執行
do{}while();先執行後判斷
比while至少多一次執行
#include <stdio.h>
#include <stdlib.h>
int main()
{
do{
printf(“111\n”);
}while(1);
system(“pause”);
return 0;
}
//第十次終止
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i=0;
do{
i++;
printf(“111\n”);
if(i == 10)
{
break;}
}while(1);
system(“pause”);
return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章