Ranks[3][0].iCountryId=RankCountrys[0].iCountryId;
Ranks[3][0].iRank=1;
for(i=1; i
if(RankCountrys[i].dPrizeRatio==RankCountrys[i-1].dPrizeRatio)
Ranks[3][i].iRank=Ranks[3][i-1].iRank;
else
Ranks[3][i].iRank=i+1;
}
//找出最佳排序方式输出 必须遍历每种排名中的每个元素 不然会漏掉
int rank,way;
bool first;
for(i=0; i
for(j=0; j<4; j++)
for(k=0; k
if(first) {
rank=Ranks[j][k].iRank;
way=j;
first=false;
} else {
if(Ranks[j][k].iRank
way=j;
}
}
}
}
printf("%d:%d\n",rank,way+1);
}
printf("\n");
}
return 0;
}
//按金牌数排序 降序
{
Country *c1=(Country*)a;
Country *c2=(Country*)b;
return c2->dGold- c1->dGold;
}
//按奖牌数排序
int cmp2(const void *a,const void *b)
{
Country *c1=(Country*)a;
Country *c2=(Country*)b;
return c2->dPrize -c1->dPrize;
}
//按金牌人口比排序
int cmp3(const void *a,const void *b)
{
Country *c1=(Country*)a;
Country *c2=(Country*)b;
return c2->dGoldRatio > c1->dGoldRatio 1:-1;
}
//按奖牌人口比排序
int cmp4(const void *a,const void *b)
{
Country *c1=(Country*)a;
Country *c2=(Country*)b;
return c2->dPrizeRatio > c1->dPrizeRatio 1:-1;
}
/**************************************************************
Problem: 1007
User: windzhu
Language: C++
Result: Accepted
Time:10 ms
Memory:1108 kb
****************************************************************/