啊哈磊_编程从这里起步
标题:
【一天一练】【2014.5.28】【学习成绩的等级问题】
[打印本页]
作者:
李掌柜
时间:
2014-5-28 21:23
标题:
【一天一练】【2014.5.28】【学习成绩的等级问题】
本帖最后由 李掌柜 于 2014-5-29 20:23 编辑
题目描述
给出一百分制成绩,要求输出成绩等级‘A’、‘B’、‘C’、‘D’、‘E’。
90分以上为A80-89分为B70-79分为C60-69分为D60分以下为E
输入
一个整数0-100以内
输出
一个字符,表示成绩等级
样例输入
90
样例输出
A
提示
分段函数返回字符
注:1 本题目来源
http://www.clang.cc
2 所有做题并贴代码的小伙伴都有机会获得1~5个啊哈币
作者:
4399APPLE2
时间:
2014-5-29 09:43
虽然我被封了号,但是我还是继续做题。
#include <stdio.h>
#include <stdlib.h>
int main()
{
int sc;
scanf("%d",&sc);
if(sc<0||sc>100)
{
puts("Error!");
getch();
exit(0);
}
if(sc>89)
putch('A');
else if(sc<90&&sc>79)
putch('B');
else if(sc<79&&sc>69)
putch('C');
else if(sc<69&&sc>59)
putch('D');
else
putch('E');
system("pause");
return 0;
}
复制代码
作者:
rosynirvana
时间:
2014-5-29 14:54
标准环境中没有putch
作者:
mengyizui
时间:
2014-6-15 21:44
#include <stdio.h>
int main (void)
{
int x = 0;
scanf ("%d", &x);
if (x >= 90)
printf ("%c", 'A');
else if (( x >= 80 ) && ( x < 90 ))
printf ("%c", 'B');
else if (( x >= 70 ) && ( x < 80 ))
printf ("%c", 'C');
else if (( x >= 60 ) && ( x < 70 ))
printf ("%c", 'D');
else
printf ("%c", 'E');
return 0;
}
作者:
hou
时间:
2014-6-20 19:04
本帖最后由 hou 于 2014-6-20 19:41 编辑
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
int main()
{
int x; scanf("%d",&x);
if(x<=100&&x>=0)
{
if(x>=90)
printf("A\n");
else if(x>=80&&x<90)
printf("B\n");
else if(x>=70&&x<80)
printf("C\n");
else if(x>=60&&x<70)
printf("D\n");
else
printf("E\n");
}
else
printf("is not a score\n");
system("pause");
return 0;
}
[/mw_shl_code]
作者:
1935515130
时间:
2014-6-22 12:26
//好吧,只能这样了……
#include <stdio.h>
main()
{
int a;
scanf("%d",&a);
if(a>=90) {printf("A");}
if(80<=a && a<90) {printf("B");}
if(70<=a && a<80) {printf("C");}
if(60<=a && a<70) {printf("D");}
if(a<60) {printf("E");}
getch();
return 0;
}
作者:
小辉~
时间:
2014-8-6 11:05
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a;
scanf("%d",&a);
if(a>=90 && a<=100)
printf("A");
if(a>=80 && a<90)
printf("B");
if(a>=70 && a<80)
printf("C");
if(a>=60 && a<70)
printf("D");
if(a<60)
printf("E");
system("pause");
return 0;
}
作者:
lsjren
时间:
2014-8-8 14:23
好好学习班.
作者:
4399APPLE
时间:
2014-12-16 20:58
到死我也要水一贴
作者:
4399APPLE
时间:
2014-12-16 20:58
到死我也要水一贴
作者:
4399APPLE
时间:
2014-12-16 20:58
到死我也要水一贴
作者:
4399APPLE
时间:
2014-12-16 20:58
到死我也要水一贴
作者:
趣味的吃
时间:
2014-12-22 18:05
贴一个:[mw_shl_code=c,true]/*给出一百分制成绩,要求输出成绩等级‘A’、‘B’、‘C’、‘D’、‘E’。
90分以上为A80-89分为B70-79分为C60-69分为D60分以下为E*/
#include<stdio.h>
#include<windows.h>
void main()
{
int a;
while(1)
{
printf("请输入一个成绩……");
scanf("%d",&a);
if(a<=100 && a>=0)
{
if(a>=90)
printf("A\n");
else if(a<=89 && a>=80)
printf("B");
else if(a<=79 && a>=70)
printf("C");
else if(a<=69 && a>=60)
printf("D");
else
printf("E");
Sleep(3000);
system("cls");
}
else
{
printf("Error!");
break;
}
}
}
对了掌柜,我在您说的原有基础上增加了while循环,可一次性读取无数个成绩,能不能加分?
[/mw_shl_code]
作者:
趣味的吃
时间:
2014-12-22 18:06
磊哥也不注意下,我本来最后一行是引用的内容,结果成代码了,我晕!
作者:
trazy
时间:
2015-9-20 15:02
#include <stdio.h>
#include <stdlib.h>
#include<time.h>
int main()
{
int x;
scanf("%d",&x);
if(x>=90&&x<=100)
printf("%c\n",'A');
if(x>=80&&x<90)
printf("%c\n",'B');
if(x>=70&&x<80)
printf("%c\n",'C');
if(x>=60&&x<70)
printf("%c\n",'D');
if(x>=0&&x<60)
printf("%c\n",'E');
system("pause");
return 0;
}
作者:
Vandals
时间:
2015-10-3 18:17
0000000000000000000
作者:
福华
时间:
2015-11-6 18:18
#include <stdio.h>
char grades(int n)
{
switch(n/10)
{
case 9:return 'A';
case 8:return 'B';
case 7:return 'C';
case 6:return 'D';
default:return 'E';
}
}
int main()
{
char c;
int n;
scanf("%d",&n);
c=grades(n);
printf("%c",c);
system("pause");
return 0;
}[mw_shl_code=c,true][/mw_shl_code]
作者:
福华
时间:
2015-11-6 18:20
福华 发表于 2015-11-6 18:18
#include
char grades(int n)
{
这个不算
作者:
福华
时间:
2015-11-6 18:20
[mw_shl_code=c,true]#include <stdio.h>
char grades(int n)
{
switch(n/10)
{
case 9:return 'A';
case 8:return 'B';
case 7:return 'C';
case 6:return 'D';
default:return 'E';
}
}
int main()
{
char c;
int n;
scanf("%d",&n);
c=grades(n);
printf("%c",c);
system("pause");
return 0;
}[/mw_shl_code]
作者:
xjzb
时间:
2018-12-31 15:21
[mw_shl_code=c,true]#include <stdio.h> #include <stdlib.h> int main() { int x; scanf("%d",&x); if(x<=100&&x>=0) { if(x>=90) printf("A\n"); else if(x>=80&&x<90) printf("B\n"); else if(x>=70&&x<80) printf("C\n"); else if(x>=60&&x<70) printf("D\n"); else printf("E\n"); } else printf("is not a score\n"); system("pause"); return 0; } [/mw_shl_code]
欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/)
Powered by Discuz! X3.2