64,691
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
using namespace std;
struct Student
{
int score[5];
char name[20];
};
int main()
{
Student st[5];
for(int i=0;i<5;i++)
cin>>st[i].name>>st[i].score;
for(int i=0;i<5;i++)
{
for(int j=i+1;j<5;j++)
{
if(st[j].score>st[i].score)
{
Student temp=st[i];
st[i]=st[j];
st[j]=temp;
}
}
}
for(int i=0;i<5;i++)
{
cout<<st[i].name<<st[i].score;}
return 0;
}
#include<iostream>
using namespace std;
struct Student
{
int score;
char name[20];
};
int main()
{
Student st[5];
for(int i=0;i<5;i++)
cin>>st[i].name>>st[i].score;
for(int i=0;i<5;i++)
{
for(int j=i+1;j<5;j++)
{
if(st[j].score>st[i].score)
{
Student temp=st[i];
st[i]=st[j];
st[j]=temp;
}
}
}
for(int i=0;i<5;i++)
{
cout<<st[i].name<<st[i].score;}
return 0;
}