输入学生的成绩,判断成绩给出评价:
1 #include <stdio.h>
2
3 int main()
4 {
5 int score;
6
7 printf("please input score:\n");
8 scanf("%d",&score);
9 if(score>90)
10 printf("you xiu\n");
11 else if(score>=60 && score<70)
12 printf("pass\n");
13 else if(score>=80 && score<90)
14 printf("liang hao\n");
15 else if(score>=70 && score<80)
16 printf("zhong deng\n");
17 else
18 printf("game over\n");
19
20 return 0;
21 }
打印结果:
注:
1、二大选择,三大循环,四大跳转
二大选择: if、switch
三大循环:while、do while、for
四大跳转:break、continue、goto、return
2、选择分为:单路选择、双路选择、多路选择(点的选择、范围的选择)
3、if后面所隶属的语句,只有一条。如果想多条语句隶属于if,请用{ }括起来。
4、else不能单独使用,else也只有一条语句隶属于它。
5、else总是先跟其前最近的且尚未配对的if进行配对。