第十四周项目二(1) 按得分输出成绩

来源:互联网 发布:中航控制卡软件 编辑:程序博客网 时间:2024/06/05 16:52

问题及代码

/**ALL rights reserved.    .*文件名称:shisizhouxiangmu2(1)    *作者:李长鸿    *完成时间:2014.12‘02    *问题描述:成绩排序   */   #include<iostream>#include<string>using namespace std;const int num=8;int main(){int i,j,t;string temp;string name[num]= {"zhao","qian","sun","li","zhou","wu","zheng","wang"};double score[num]= {79,84,65,89,60,92,78,56};//(1)按成绩排序并输出结果for(i=1;i<=7;i++){    for(j=0;j<=6;j++)        if(score[j]<score[j+1])    {        t=score[j];        score[j]=score[j+1];        score[j+1]=t;        temp=name[j];        name[j]=name[j+1];        name[j+1]=temp;    }}cout<<"按成绩排序为:"<<endl;for(i=0;i<=7;i++)    cout<<name[i]<<": "<<score[i]<<endl;}   

 

0 0
原创粉丝点击