C语言编程小实战-----switch

1 ,基本的选择语句的使用switch

C语言编程小实战-----switch_第1张图片

int score;

while(score != 100){//放到下面的

printf("输入你的分数:\n");

scanf("%d",&score);

if(score < 0 || score > 100){

printf("你输入的分数不合法:\n");

continue;//结束本次循环,进行下一次的循环

}

else {

int rank = (int)score/10;

switch(rank){

case 9: printf("your rank is A");

break;

case 8: printf("your rank is B");

break;

case 7: printf("your rank is C");

break;

case 6: printf("your rank is D");

break;

default: printf("your rank is E");

}

}

}

return 0;

简单的成绩等级

你可能感兴趣的:(C语言编程小实战-----switch)