pifwgepx8 1 year ago
parent 1eec7c6dc0
commit f600b71570

@ -0,0 +1,60 @@
#include <stdio.h>
int main(){
float a[4]={99.5,77.9,92.5,0},b[4]={88.5,56.5,99.0,0},c[4]={89.5,87.5,60.5,0};
int s[4]={10001,10002,10003,0},class[4]={11,12,11,0};
scanf("%d%d%f%f%f",&s[3],&class[3],&a[3],&b[3],&c[3]);
int m;
m=s[3];
int i,j;
float t;
for(i=0;i<3;i++)
{
for(j=i+1;j<3;j++)
{
if(class[i]>class[j])
{
t=s[j];
s[j]=s[i];
s[i]=t;
t=class[j];
class[j]=class[i];
class[i]=t;
t=a[j];
a[j]=a[i];
a[i]=t;
t=b[j];
b[j]=b[i];
b[i]=t;
t=c[j];
c[j]=c[i];
c[i]=t;
}
if(class[i]=class[j]&&(a[i]+b[i]+c[i])<(a[j]+b[j]+c[j]))
{
t=s[j];
s[j]=s[i];
s[i]=t;
t=class[j];
class[j]=class[i];
class[i]=t;
t=a[j];
a[j]=a[i];
a[i]=t;
t=b[j];
b[j]=b[i];
b[i]=t;
t=c[j];
c[j]=c[i];
c[i]=t;
}
}
}
for(i=0;i<4;i++)
{
printf("%d %d %.1f %.1f %.1f\n",s[i],class[i],a[i],b[i],c[i]);
if(s[i]==m)
printf("inserted\n");
}
return 0;
}
Loading…
Cancel
Save