是
冒泡排序就可以了啊
struct stu
{
int nid;
float fscore;
};
void sort(struct stu *ps, int n)
{
for (int i = 0; i < n-1; i++)
for (int j = 0; j < n - i - 1; j++)
{
if (ps[j].fscore < ps[j + 1].fscore)
{
struct stu s = ps[j];
ps[j] = ps[j + 1];
ps[j + 1] = s;
}
}
}
void main()
{
struct stu ps[100];
int N,i;
scanf("%d", &N);
for (i = 0; i < N; i++)
scanf("%d %f", &ps[i].nid, &ps[i].fscore);
sort(ps, N);
int nIdx = 1;
float pScore;
for (i = 0; i < N; i++)
{
if (i == 0)
{
printf("%d %d %f\n", nIdx,ps[i].nid,ps[i].fscore);
pScore = ps[i].fscore;
}
else
{
if (ps[i].fscore == pScore)
{
printf("%d %d %f\n", nIdx, ps[i].nid, ps[i].fscore);
}
else
{
nIdx++;
printf("%d %d %f\n", nIdx, ps[i].nid, ps[i].fscore);
pScore = ps[i].fscore;
}
}
}
}