chengji

来源:互联网 发布:杭州知彼 编辑:程序博客网 时间:2024/06/05 13:27
#include<iostream>using namespace std;struct student{    string name;    double score;};int main(){    student stu[5],s;    for(int i=0; i<5; i++)    {        cin>>stu[i].name>>stu[i].score;    }    for(int i=0; i<5; i++)    {        for(int j=i+1; j<5; j++)        {            if(stu[i].score>stu[j].score)            {                s=stu[j];                stu[j]=stu[i];                stu[i]=s;            }        }    }    cout<<"MAX:  "<<stu[4].name<<"  "<<stu[4].score<<endl;    cout<<"MIN:"<<stu[0].name<<" "<<stu[0].score<<endl;    return 0;}

0 0
原创粉丝点击