C语言题目
请问这道题目怎么用C语言写,我上传了图片,感谢大噶{:10_254:} {:10_282:} #if 0By Cool_Breeze
Dev-C++ 5.11
x.c
#endif
#include <stdio.h>
#include <string.h>
void sawp(float* p1, float* p2,short len);
int main(void)
{
static float Achievement;
//0学号,1语文,2数学,3英语,4三科总和;
short n=0;
scanf("%d",&n);
getchar();
register short i=0;
for (i=0;i<n;i++)
{
Achievement=i+1;
scanf("%f %f %f",&Achievement,&Achievement,&Achievement);
getchar();
Achievement=Achievement+Achievement+Achievement;
}
//sort
register short j=0;
for (i=0;i<n-1;i++)
for (j=i+1;j<n;j++)
{
if (Achievement > Achievement)
{
sawp(&Achievement,&Achievement,5);
continue;
}
else if (Achievement == Achievement)//总成绩相等
{
if(Achievement == Achievement)//语文相等
{
if (Achievement > Achievement)// 比较学号
sawp(&Achievement,&Achievement,5);
continue;
}
else if (Achievement > Achievement)
{
sawp(&Achievement,&Achievement,5);
continue;
}
}
}
for (i=0;i<5;i++)//前5名
printf("%f %f\n",Achievement,Achievement);
return 0;
}
void sawp(float* p1, float* p2,short len)
{
register float t=0;
for (;len>0;p1++,p2++,len--)
t=*p1,*p1=*p2,*p2=t;
}
6
90 67 80
87 66 91
78 89 91
88 99 77
67 89 64
78 89 98
6.000000 265.000000
4.000000 264.000000
3.000000 258.000000
2.000000 244.000000
1.000000 237.000000
--------------------------------
Process exited after 11.32 seconds with return value 0
请按任意键继续. . . Cool_Breeze 发表于 2020-5-5 20:10
感谢感谢{:10_275:}
页:
[1]