| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1374 人关注过本帖
标题:求成绩等级
只看楼主 加入收藏
xiaotan
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2006-5-5
收藏
 问题点数:0 回复次数:18 
求成绩等级

给100分制成绩,要求输出成绩等级‘A’,‘B’,‘C’,‘D’,‘E’。90分以上为‘A’,80-90为
‘B’,70-80为‘C’,60-70为‘D’,60分以下为‘E’。
#include<stdio.h>
#include<math.h>
main()
{
int x,k;

printf("\nplease input an score:\n");
scanf("%d",&x);
if(x>=90 && x=<100)
k=1;
if(x>=80 && x=<90)
k=2;
if(x>=70 && x=<80)
k=3;
if(x>=60 && x=<70)
k=4;
if(x<60)
k=5;

swicth(k)
{case 1: printf("\nthe score belong to A !\n");break;
case 2: printf("\nthe score belong to B !\n");break;
case 3: printf("\nthe score belong to c !\n");break;
case 4: printf("\nthe score belong to D !\n");break;
case 5: printf("\nthe score belong to d !\n");break;
default:printf("error!");
}
不知道为什么,这个程序也是有错误的,老是那个错误!说缺少一个小的括号!
我想不明白啊!这个程序不难!算法简单!但是我就是做的不对!请各位高手指点小弟啊!

搜索更多相关主题的帖子: 等级 
2006-05-13 19:12
luo113927
Rank: 1
等 级:新手上路
帖 子:173
专家分:0
注 册:2006-3-15
收藏
得分:0 
x>=90 x=<90 x>=80 x=<80 x>=70 x=<70

如果给你,你怎么判断啊?

2006-05-13 19:17
adsl0231
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2006-3-29
收藏
得分:0 
以下是引用xiaotan在2006-5-13 19:12:00的发言:

给100分制成绩,要求输出成绩等级‘A’,‘B’,‘C’,‘D’,‘E’。90分以上为‘A’,80-90为
‘B’,70-80为‘C’,60-70为‘D’,60分以下为‘E’。
#include<stdio.h>
#include<math.h> //这个头文件好像没用到阿!!
main()
{
int x,k;

printf("\nplease input an score:\n");
scanf("%d",&x);
if(x>=90 && x=<100)
k=1;
if(x>=80 && x=<90) //if(x>=80 && x<90)
k=2;
if(x>=70 && x=<80) //if(x>=70 && x<80)
k=3;
if(x>=60 && x=<70) //if(x>=60 && x<70)
k=4;
if(x<60)
k=5;

swicth(k) //switch(k)
{case 1: printf("\nthe score belong to A !\n");break;
case 2: printf("\nthe score belong to B !\n");break;
case 3: printf("\nthe score belong to C !\n");break;
case 4: printf("\nthe score belong to D !\n");break;
case 5: printf("\nthe score belong to E !\n");break;
default:printf("error!");
}
不知道为什么,这个程序也是有错误的,老是那个错误!说缺少一个小的括号!
我想不明白啊!这个程序不难!算法简单!但是我就是做的不对!请各位高手指点小弟啊!

[此贴子已经被作者于2006-5-13 19:54:05编辑过]


2006-05-13 19:48
论坛
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:1372
专家分:0
注 册:2006-3-27
收藏
得分:0 
我真为你们感到伤心,这样的问题自己都搞不定

日出东方,唯我不败! 做任何东西都是耐得住寂寞,任何一个行业要有十年以上的积累才能成为专家
2006-05-13 21:02
论坛
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:1372
专家分:0
注 册:2006-3-27
收藏
得分:0 

#include<stdio.h>

int main(void)
{
int x, k;

printf("\nplease input an score:\n");
scanf("%d", &x);

if (x > 90 && x <= 100)
{
k=1;
}
else if(x > 80 && x <= 90)
{
k=2;
}
else if(x > 70 && x <= 80)
{
k=3;
}
else if(x > 60 && x <= 70)
{
k=4;
}
else
{
k=5;
}

switch(k)
{
case 1:
printf("\nthe score belong to A !\n");
break;
case 2:
printf("\nthe score belong to B !\n");
break;
case 3:
printf("\nthe score belong to C !\n");
break;
case 4:
printf("\nthe score belong to D !\n");
break;
case 5:
printf("\nthe score belong to E !\n");
break;
default:
printf("error!");
}

return 0;
}



日出东方,唯我不败! 做任何东西都是耐得住寂寞,任何一个行业要有十年以上的积累才能成为专家
2006-05-13 21:09
空中鱼
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-5-14
收藏
得分:0 
main()
{
int x,k;

printf("\nplease input an score:\n");
scanf("%d",&x);
if(x>=90 && x=<100)
k=1;
if(x>=80 && x=<90) //if(x>=80 && x<90)
k=2;
if(x>=70 && x=<80) //if(x>=70 && x<80)
k=3;
if(x>=60 && x=<70) //if(x>=60 && x<70)
k=4;
if(x<60)
k=5;

swicth(k) //switch(k)
{case 1: printf("\nthe score belong to A !\n");break;
case 2: printf("\nthe score belong to B !\n");break;
case 3: printf("\nthe score belong to C !\n");break;
case 4: printf("\nthe score belong to D !\n");break;
case 5: printf("\nthe score belong to E !\n");break;
default:printf("error!");
}
}

应该这样

2006-05-14 11:20
空中鱼
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-5-14
收藏
得分:0 
if(x>=90 && x=<100)也要改为if(x>=90 && x<=100)
才可以
2006-05-14 11:25
走刀口→超
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5018
专家分:0
注 册:2006-3-14
收藏
得分:0 

#include<stdio.h>
main()
{ int score,mark;
printf("\nplease input an score:\n");
scanf("%d",&score);
mark=score/10;
switch(mark)
{
case 10:
case 9: printf("\nthe score belong to A !\n");break;
case 8: printf("\nthe score belong to B !\n");break;
case 7: printf("\nthe score belong to c !\n");break;
case 6: printf("\nthe score belong to D !\n");break;
case 5: printf("\nthe score belong to d !\n");break;
default:printf("error!");
}
}


人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...
2006-05-14 12:40
gaga
Rank: 1
等 级:新手上路
威 望:2
帖 子:307
专家分:0
注 册:2006-4-5
收藏
得分:0 
你的程序我没有动就加个括号:

以下是引用xiaotan在2006-5-13 19:12:00的发言:

给100分制成绩,要求输出成绩等级‘A’,‘B’,‘C’,‘D’,‘E’。90分以上为‘A’,80-90为
‘B’,70-80为‘C’,60-70为‘D’,60分以下为‘E’。
#include<stdio.h>
#include<math.h>
main()
{
int x,k;

printf("\nplease input an score:\n");
scanf("%d",&x);
if(x>=90 && x=<100)
k=1;
if(x>=80 && x=<90)
k=2;
if(x>=70 && x=<80)
k=3;
if(x>=60 && x=<70)
k=4;
if(x<60)
k=5;

swicth(k)
{case 1: printf("\nthe score belong to A !\n");break;
case 2: printf("\nthe score belong to B !\n");break;
case 3: printf("\nthe score belong to c !\n");break;
case 4: printf("\nthe score belong to D !\n");break;
case 5: printf("\nthe score belong to d !\n");break;
default:printf("error!");
}
}/*注意这个括号*/
不知道为什么,这个程序也是有错误的,老是那个错误!说缺少一个小的括号!
我想不明白啊!这个程序不难!算法简单!但是我就是做的不对!请各位高手指点小弟啊!

[此贴子已经被作者于2006-5-14 12:50:06编辑过]


明天的明天还有明天。 可是今天却只有一个。 public Copy from 无缘今生
2006-05-14 12:49
走刀口→超
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5018
专家分:0
注 册:2006-3-14
收藏
得分:0 
昏。我刚刚写的时候也少了这个。不过他的程序有算法错误。当然楼上的有改正了!

人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...
2006-05-14 12:54
快速回复:求成绩等级
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019813 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved