c语言输入三个分数,并进行按从高到低等级进行排序,再输出结果
#include <stdio.h>
float a,b,c;
void sortabc();
void putabc();
char grade(float x);
int main(int argc, const char * argv[])
{
float a,b,c;
scanf("%f,%f,%f",&a,&b,&c);
sortabc();
grade(a);
putabc();
}
void sortabc()
{
float t;
if(a<b)
{t=a;a=b;b=t;}
if(b<c)
{t=b;c=b;c=t;}
if (a<b)
{t=a;a=b;b=t;}
}
char grade(float x)
{
if(x>=85)
return ('A');
else
if (x>70)
{
return ('B');
}
else
if (x>=60)
{
return ('c');
}
else
return ('D');
}
void putabc()
{
char g;
g=grade(a);
printf("%6.1f:%c",a,g);
g=grade(b);
printf("%6.1f:%c",b,g);
g=grade(c);
printf("%6.1f:%c",c,g);
}
补充:软件开发 , C语言 ,