56 lines
1.2 KiB
C
56 lines
1.2 KiB
C
|
#include<stdio.h>
|
|||
|
#include<stdlib.h>
|
|||
|
#include<string.h>
|
|||
|
|
|||
|
typedef struct game {
|
|||
|
char name[8]; /* <20><><EFBFBD>ɪ̩m<CCA9>W */
|
|||
|
int score; /* <20>o<EFBFBD><6F> */
|
|||
|
}GAME;
|
|||
|
|
|||
|
|
|||
|
int main(){
|
|||
|
|
|||
|
int i=0 ,j=0 ,n ;
|
|||
|
GAME temp;
|
|||
|
char input[20];
|
|||
|
GAME * bowling = (GAME*)malloc(sizeof(GAME));
|
|||
|
printf("<EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><EFBFBD><EFBFBD>ɪ̸<EFBFBD><EFBFBD>T\n");
|
|||
|
while(1){
|
|||
|
|
|||
|
printf("<EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD><EFBFBD>ɪ̦W<CCA6>r <20>o<EFBFBD><6F> => ",i+1);
|
|||
|
|
|||
|
// fgets(input,sizeof(input),stdin);
|
|||
|
if(fgets(input,sizeof(input),stdin) == NULL||(strcmp(input,"\n")) == 0 ){
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
bowling = (GAME*)realloc(bowling ,(i+1)* sizeof(GAME));
|
|||
|
sscanf(input,"%s%d",bowling[i].name,&bowling[i].score);
|
|||
|
i++;
|
|||
|
n=i;
|
|||
|
}
|
|||
|
|
|||
|
for(i=0;i<n;i++){
|
|||
|
for(j=0;j<n-i-1;j++){
|
|||
|
if(bowling[j].score<bowling[j+1].score){
|
|||
|
temp = bowling[j+1];
|
|||
|
bowling[j+1]=bowling[j];
|
|||
|
bowling[j]=temp;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
printf("<EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD>Ʀ<EFBFBD>\n");
|
|||
|
printf("==============\n");
|
|||
|
for(i=0;i<n;i++){
|
|||
|
if(i+1==1) printf("%d. %s\t%d <20>a<EFBFBD>x\n",i+1,bowling[i].name,bowling[i].score);
|
|||
|
else if(i+1==2) printf("%d. %s\t%d <20>ȭx\n",i+1,bowling[i].name,bowling[i].score);
|
|||
|
else if(i+1==3) printf("%d. %s\t%d <20>u<EFBFBD>x\n",i+1,bowling[i].name,bowling[i].score);
|
|||
|
else
|
|||
|
printf("%d. %s\t%d\n",i+1,bowling[i].name,bowling[i].score);
|
|||
|
}
|
|||
|
|
|||
|
free(bowling);
|
|||
|
return 0 ;
|
|||
|
}
|
|||
|
|