- 分享
- 0
- 人气
- 0
- 主题
- 14
- 帖子
- 2007
- UID
- 96129
- 积分
- 1491
- 阅读权限
- 18
- 注册时间
- 2007-8-28
- 最后登录
- 2017-6-16
- 在线时间
- 3887 小时
|
else-if 和 if-else 有什么不同?
我是学院生,工程系的,programming module照着课程跑的,一个星期才4小时而已。所以学的东西很有限很基础。大部分comands不知道。
课程到:switch, looping(for/while/do-while), array storage而已。
以下自己纠正回来了。
#include <stdio.h>
main()
{
char grade1='A', grade2='B', grade3='C', grade4='D',grade5='F';
int totalnum=0, count=1, score;
int num_a=0, num_b=0, num_c=0, num_d=0, num_f=0;
printf("How many test scores?");
scanf("%d", &totalnum);
while(count<=totalnum)
{
printf("\nEnter test score %d : ", count);
scanf("%d", &score);
if(score<=100 && score>=0) \\少了这个,难怪不能progress...排泄
{
if(score<=100 && score>=80)
{
printf("You scored %c\n\n", grade1);
num_a = num_a + 1;
}
else
{
if(score<=79 && score>=70)
{
printf("You scored %c\n\n", grade2);
num_b = num_b + 1;
}
else
{
if(score<=69 && score>=60)
{
printf("You scored %c\n\n", grade3);
num_c = num_c + 1;
}
else
{
if(score<=59 && score>=50)
{
printf("You scored %c\n\n", grade4);
num_d = num_d + 1;
}
else
{
if(score<=49 && score>=0)
{
printf("You scored %c\n\n", grade5);
num_f = num_f + 1;
}
}
}
}
}
}
else
{
printf("\nInvalid value!");
}
count = count + 1;
}
printf("\n\nNumber of students scoring 'A': %d", num_a);
printf("\nNumber of students scoring 'B': %d", num_b);
printf("\nNumber of students scoring 'C': %d", num_c);
printf("\nNumber of students scoring 'D': %d", num_d);
printf("\nNumber of students scoring 'F': %d", num_f);
printf("\n\n\nBye...\n\n");
}
[ 本帖最后由 无我不在 于 2008-11-27 08:19 PM 编辑 ] |
|