?? pku2218.cpp
字號:
#include <stdio.h>
#include <string.h>
typedef struct
{
char name[21];
int weight;
} People ;
int cp(void *a, void *b)
{
People *c = (People *)a;
People *d = (People *)b;
return d->weight - c->weight;
}
int main()
{
char s[21];
People pe[11];
int i,n,day,wei;
while(scanf("%s",s)!=-1)
{
i=0;
while(scanf("%s",s)!=-1)
{
if(strcmp(s,"END")==0) break;
strcpy(pe[i].name,s);
scanf("%d%d",&day,&wei);
pe[i].weight=wei-day;
i++;
}
n=i;
qsort(pe,n,sizeof(People),cp);
for(i=0;i<n;i++)
{
printf("%s\n",pe[i].name);
}
printf("\n");
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -