#include<bits/stdc++.h>
using namespace std;
struct node
{
char name[25];
int score;
} a[15];
bool operator <(struct node x,struct node y)
{
if(strcmp(x.name,y.name)<0)return 1;
else return 0;
}
int main()
{
for(int i=0; i<10; i++)
scanf("%s\n",a[i].name);
for(int i=0; i<10; i++)
scanf("%d",&a[i].score);
sort(a,a+10);
for(int i=0; i<10; i++)
printf("%s,%d\n",a[i].name,a[i].score);
}SDUT1334简单字符串排序
最新推荐文章于 2022-10-17 13:04:13 发布
本文介绍了一个使用C++实现的结构体排序程序示例。该程序定义了一个包含姓名和分数字段的结构体,并通过自定义比较函数实现了基于姓名的排序。最后,程序输出了排序后的姓名和对应的分数。
1016

被折叠的 条评论
为什么被折叠?



