c语言swich用法
- 提问者网友:欺烟
- 2021-05-01 18:22
- 五星知识达人网友:撞了怀
- 2021-05-01 18:30
#include "stdio"
main()
{
int a ;
scanf("%d",&a);
if(a>=0&&a<=100)
{
switch(a/10)
{
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");
}
}
else
printf("您的输入有误,请重新输入");
}
- 1楼网友:青灯有味
- 2021-05-01 21:05
char a;
scanf("请输入A、B、C、D、E",a);
switch(a)
{
case 'A': printf("90-100");
break;
case 'B': printf("80-89");
break;
case 'C': printf("70-79");
break;
case 'D': printf("60-69");
break;
case 'E': printf("0-59");
break;
}
- 2楼网友:底特律间谍
- 2021-05-01 20:42
char ch;
scanf("%c",&ch);
switch(ch)
{
case 'A':
printf("90-100");
break;
case 'B':
printf("80-89");
break;
case 'C':
printf("70-79");
break;
case 'D':
printf("60-69");
break;
case 'E':
printf("0-59");
break;
default:printf("Please input a proper character.\n");
}
- 3楼网友:迟山
- 2021-05-01 19:34
*********您好!Yadie.23很高兴能为你解答。********* +++++++++++++++++++++++++++++++++++++++++++++++++
#include<stdio.h> #include<conio.h> void main() { char ch; scanf("%c",&ch); switch(ch) { case 'A':printf("100~90");break; case 'B':printf("89~80");break; case 'C':printf("79~70");break; case 'D':printf("69~60");break; case 'E':printf("59~0");break; default :printf("Error!"); } getch(); }
+++++++++++++++++++++++++++++++++++++++++++++++++ You can have a try,maybe my answer useful to you. 如满意,Yadie.23十分感谢您的采纳。*^-^*
- 4楼网友:独钓一江月
- 2021-05-01 19:02
char chInput;
.....
switch(chInput)
{
case 'A':
printf("");
break;
case 'B':
printf("");
break;
case 'C':
printf("");
break;
case 'D':
printf("");
break;
}