求C语言!用switch编写一个计算分段函数的程序!

如题所述

main()
{
int
a,b,c;//a是输入测试值,b是分段值,c是条件标志
printf("input
the
value
and
percentils:\n");
scanf("%d
%d",&a,&b);
//判断a值
if(a>=b)
c=1;
else
c=0;
switch(c)
{
case
1;//a的函数计算
;break;
default://a的函数计算
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2020-01-16
//100分制
#include
<stdio.h>
void
main()
{
int
score,t;
printf("输入成绩:");
scanf("%d",&score);
t=score/10;//t的取值0,1,2,3,4,5,6,7,8,9,10
switch(t)
{
case
0:
case
1:
case
2:
case
3:
case
4:
case
5:printf("不及格\n");break;
case
6:printf("及格\n");break;
case
7:
case
8:printf("良好\n");break;
case
9:
case
10:printf("优秀\n");break;
}
}