74 lines
1.7 KiB
C
74 lines
1.7 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() {
|
|||
|
GAME *bowling ; // <20>ʺA<CABA><41><EFBFBD>t<EFBFBD>O<EFBFBD><4F><EFBFBD>骺<EFBFBD><E9AABA><EFBFBD><EFBFBD>
|
|||
|
int total = 0; // <20><><EFBFBD>ɪ̼ƶq
|
|||
|
int i , j ,temp;
|
|||
|
char input[32]; // <20>Ȧs<C8A6>ΨӳB<D3B3>z<EFBFBD><7A><EFBFBD>J
|
|||
|
|
|||
|
printf("<EFBFBD>гv<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><EFBFBD><EFBFBD>ɪ̪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>T...\n");
|
|||
|
while (1) {
|
|||
|
// <20><><EFBFBD>ܿ<EFBFBD><DCBF>J<EFBFBD><4A><EFBFBD>ɪ̦W<CCA6>ٻP<D9BB>o<EFBFBD><6F>
|
|||
|
printf("<EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD><EFBFBD>ɪ̦W<CCA6>r <20>o<EFBFBD><6F> => ", total + 1);
|
|||
|
|
|||
|
// Ū<><C5AA><EFBFBD>@<40><><EFBFBD><EFBFBD><EFBFBD>J
|
|||
|
fgets(input, sizeof(input), stdin);
|
|||
|
|
|||
|
// <20>Y<EFBFBD><59><EFBFBD>U<Enter><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>J<EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>J<EFBFBD>L<EFBFBD>{
|
|||
|
if (strcmp(input, "\n") == 0) {
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
// <20>ʺA<CABA><41><EFBFBD>t<EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD><EFBFBD>Ŷ<EFBFBD><C5B6>H<EFBFBD>O<EFBFBD>s<EFBFBD>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD>ɪ̸<C9AA><CCB8><EFBFBD>
|
|||
|
bowling = (GAME *)malloc( (total + 1) * sizeof(GAME));
|
|||
|
|
|||
|
// printf("<22><><EFBFBD>t<EFBFBD><74><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>}: %p\n", (void *)bowling);
|
|||
|
|
|||
|
// <20>ѪR<D1AA><52><EFBFBD>J<EFBFBD><4A><EFBFBD>W<EFBFBD>٩M<D9A9>o<EFBFBD><6F>
|
|||
|
sscanf(input, "%s %d", bowling[total].name, &bowling[total].score);
|
|||
|
|
|||
|
total++;
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD>ܿ<EFBFBD><DCBF>J<EFBFBD><4A><EFBFBD>G
|
|||
|
|
|||
|
|
|||
|
|
|||
|
printf("\n<EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD>ƦW\n============\n");
|
|||
|
|
|||
|
for (i=0 ; i<total-1;i++){
|
|||
|
for(j=0 ; j<total-i-1;j++){
|
|||
|
if (bowling[j].score<bowling[j+1].score){
|
|||
|
temp = bowling[j+1].score;
|
|||
|
bowling[j+1].score = bowling[j].score;
|
|||
|
bowling[j].score = temp;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
for (i = 0; i < total; i++) {
|
|||
|
if(i + 1==1)
|
|||
|
printf("%d. %s %d <20>a<EFBFBD>x\n", i + 1, bowling[i].name, bowling[i].score);
|
|||
|
else if(i + 1==2)
|
|||
|
printf("%d. %s %d <20>ȭx\n", i + 1, bowling[i].name, bowling[i].score);
|
|||
|
else if(i + 1==3)
|
|||
|
printf("%d. %s %d <20>u<EFBFBD>x\n", i + 1, bowling[i].name, bowling[i].score);
|
|||
|
else if (i + 1 >3)
|
|||
|
printf("%d. %s %d\n", i + 1, bowling[i].name, bowling[i].score);
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ʺA<CABA>O<EFBFBD><4F><EFBFBD><EFBFBD>
|
|||
|
free(bowling);
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|