马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 caspar 于 2016-4-8 14:09 编辑 #include <iostream>
#include <string>
using namespace std;
class Player
{
public:
char num[4];
double grade;
};
int main()
{
Player a[12]={{"001",13.6},{"002",14.8},{"010",12.0},
{"011",12.7},{"023",15.6},{"025",13.4},
{"031",14.9},{"036",12.6},{"037",13.4},
{"102",12.5},{"325",15.3},{"438",12.7}};
Player temp;
for (int i=1;i<12;i++)
{
for (int j=0;j<12-i;j++)
{
if (a[j].grade>a[j+1].grade)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for (int i=1;i<13;i++)
{
cout<<"名次为"<<i<<"的运动员号为:"<<a[i].num<<" 成绩为:"<<a[i].grade<<endl;
}
system("pause");
return 0;
}
|