#include <stdio.h>
int N;
struct data
{
char name[20];
int score;
int number;
int rank;
} grade[100];
void input()
{
FILE *in = fopen("input.txt", "r");
for(N=0; ; N++){
if(scanf("%s %d", grade[N].name, &grade[N].score) < 2){
break;
}
grade[N].number = N;
}
}
void output()
{
FILE *out = fopen("output.txt", "w");
int i;
printf(" À̸§ Á¡¼ö µî¼ö \n");
for(i=0; i<N; i++){
printf("%6s %4d %4d \n", grade[i].name, grade[i].score, grade[i].rank);
}
}
void sort()
{
int i,j;
struct data imsi;
for(i=0; i<N-1; i++){
for(j=i+1; j<N; j++){
if(grade[i].score < grade[j].score){
imsi = grade[i];
grade[i] = grade[j];
grade[j] = imsi;
}
}
}
grade[0].rank = 1;
for(i=1; i<N; i++){
if(grade[i].score == grade[i-1].score){
grade[i].rank = grade[i-1].rank;
}
else {
grade[i].rank = i+1;
}
}
for(i=0; i<N-1; i++){
for(j=i+1; j<N; j++){
if(grade[i].number > grade[j].number){
imsi = grade[i];
grade[i] = grade[j];
grade[j] = imsi;
}
}
}
}
int main()
{
input();
sort();
output();
return 0;
}
À§ ÄÚµå·Î °á°ú¿¡ ¸Â°Ô ³ª¿À´Â°É È®ÀÎÇÏ°í Á¦ÃâÇߴµ¥ wrong answer°¡ ³ª¿Í Áú¹®µå¸³´Ï´Ù.
(Ç¥ÁØÀÔÃâ·Â ¹æ½ÄÀ¸·Î ¹Ù²å½À´Ï´Ù. fcloseÀÌ·±°Íµéµµ ´Ù Áö¿ü±¸¿ä. ¾È±×·³ runtime error°¡ ³ª´õ¶ó±¸¿ä.)