#include <stdio.h>
#include <stdlib.h>
typedef struct Person
{
int age;
char name[101];
} Person;
// 작은순대로 return 값이 음수면 그대로 유지
int compare(void const *a, void const*b){
Person const *A=(void const *)a;
Person const *B=(void const *)b;
if (A->age == B-> age) return -1;
else return A->age - B->age;
}
Person arr[100000];
int main() {
int n;
scanf("%d",&n);
for (int i=0; i<n; i++) {
scanf("%d %s",&arr[i].age, arr[i].name);
}
qsort(arr, n, sizeof(Person), compare);
for (int i=0; i<n; i++) {
printf("%d %s\n",arr[i].age, arr[i].name);
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: