C语言程序设计求解,高手来救我!!!
编程序,输入一个百分制的成绩,按下式输出它的等级,要求用SWITCH结构完成.90~100为”A”,80~90为”B”,70~90为”C”,60~69为”D”,59~0为...
编程序,输入一个百分制的成绩,按下式输出它的等级,要求用SWITCH结构完成.90~100为”A”,80~90为”B”,70~90为”C”,60~69为”D”,59~0为”E”.
展开
4个回答
展开全部
#include<stdio.h>
int main()
{
unsigned int score,level;
printf("请输入您的成绩:");
scanf("%d",&score);
level = score / 10 ;
printf( "您的等级是:" );
switch ( level )
{
case 10:
case 9:
printf( "A" );
break;
case 8:
printf( "B" );
break;
case 7:
printf( "C" );
break;
case 6:
printf( "D" );
break;
default:
printf( "E" );
}
printf( "\n" );
return 0;
}
程序很简单,主要在于开关语句switch的用法。
int main()
{
unsigned int score,level;
printf("请输入您的成绩:");
scanf("%d",&score);
level = score / 10 ;
printf( "您的等级是:" );
switch ( level )
{
case 10:
case 9:
printf( "A" );
break;
case 8:
printf( "B" );
break;
case 7:
printf( "C" );
break;
case 6:
printf( "D" );
break;
default:
printf( "E" );
}
printf( "\n" );
return 0;
}
程序很简单,主要在于开关语句switch的用法。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include"math.h"
main()
{
int a,b,c;
printf("please input the score:");
scanf("%d",&a);
printf("\n");
b=(a-40)/10;
c=b/abs(b);
switch (c)
{
case -1:
printf("E");
break;
case 0:
printf("E");
break;
case 1:
switch (b)
{
case 6:
printf("A");
break;
case 5:
printf("A");
break;
case 4:
printf("B");
break;
case 3:
printf("C");
break;
case 2:
printf("D");
break;
case 1:
printf("E");
break;
case 0:
printf("E");
}
}
getch();
}
main()
{
int a,b,c;
printf("please input the score:");
scanf("%d",&a);
printf("\n");
b=(a-40)/10;
c=b/abs(b);
switch (c)
{
case -1:
printf("E");
break;
case 0:
printf("E");
break;
case 1:
switch (b)
{
case 6:
printf("A");
break;
case 5:
printf("A");
break;
case 4:
printf("B");
break;
case 3:
printf("C");
break;
case 2:
printf("D");
break;
case 1:
printf("E");
break;
case 0:
printf("E");
}
}
getch();
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<stdio.h>
#include<math.h>
main()
{
int grade,i;
printf("please input the score:");
scanf("%d",&grade);
i=(grade-60)/10;
switch (i)
{
case 0: printf("D"); break;
case 1: printf("C"); break;
case 2: printf("B"); break;
case 3: printf("A"); break;
case 4: printf("A"); break;
default;printf("E");
}
printf("/n");
}
#include<math.h>
main()
{
int grade,i;
printf("please input the score:");
scanf("%d",&grade);
i=(grade-60)/10;
switch (i)
{
case 0: printf("D"); break;
case 1: printf("C"); break;
case 2: printf("B"); break;
case 3: printf("A"); break;
case 4: printf("A"); break;
default;printf("E");
}
printf("/n");
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用switch!!!!
或用if
明显是C语言程序的题目!
或用if
明显是C语言程序的题目!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询