看看是不是这个结果:
#include <stdio.h>
#define N 16
typedef struct
{ char num[10];
int s;
}STREC;
int fun( STREC *a, STREC *b )
{ int min=a[0].s,i,t=0;
for(i=0;i<15;i++)
if(a[i].s>a[i+1].s)
min=a[i+1].s;
for(i=0;i<=16;i++)
{if(a[i].s==min)
{
a[i+1].s=a[i].s;
b+=t;
t++;
}
}
return t;
}
int main()
{ STREC s[N]={{"GA05",85},{"GA03",76},{"GA02",69},{"GA04",85},
{"GA01",91},{"GA07",72},{"GA08",64},{"GA06",87},
{"GA015",85},{"GA013",91},{"GA012",64},{"GA014",91},
{"GA011",91},{"GA017",64},{"GA018",64},{"GA016",72}};
STREC h[N];
int i;
int n=fun(s,h);
for(i=0;i<n; i++)
printf("%s %4d\n",h[i].num,h[i].s);
return 0;
}