/*
*Copyright (c) 2014, 烟台大学计算机学院
*All rights reserved.
*文件名称:test.cpp
*作者:陈栋梁
*完成日期:2014年 12 月 2 日
*版本号:v1.0
*
*问题描述:
*/
#include<iostream>
#include<string>
using namespace std;
const int num=8;
int main()
{
int i,j,t;
string temp;
string name[num]= {"赵一","钱二","孙三","李四","周五","吴六","郑七","王八"};
double score[num]= {75,84,66,92,60,92,78,56};
for (j=0; j<num-1; ++j)
for (i=0; i<num-1-j; ++i)
{
if (score[i]<score[i+1])
{
t=score[i];
score[i]=score[i+1];
score[i+1]=t;
temp=name[i];
name[i]=name[i+1];
name[i+1]=temp;
}
}
for (i=0; i<num; ++i)
cout << name[i] << " : " << score[i] << endl;
}
运行结果“