Language: C

#include<stdio.h>
 
typedef struct{
  char suit;
  char num;
  int idx;
}Card;
 
void print(Card* A, int N){
  int i;
  for(i = 0; i < N; i++){
    if(i) printf(" ");
    printf("%c%c",A[i].suit,A[i].num);
  }
  printf("\n");
}
 
void is_stable(Card* A, int N){
  int i;
  for(i = 0; i+1 < N; i++)
    if(A[i].num == A[i+1].num && A[i].idx > A[i+1].idx){
      printf("Not stable\n");
      return;
    }
  printf("Stable\n");
}
 
void swap(Card* a, Card* b){
  Card tmp = *a;
  *a = *b;
  *b = tmp;
}
 
int bubble_sort(Card* A, int N){
  int i,j, cnt=0;
  for(i = 0; i < N; i++)
    for(j = N-1; j >= i+1; j--)
      if(A[j].num < A[j-1].num){
    swap(&A[j],&A[j-1]);
    cnt++;
      }
  return cnt;
}
 
int selection_sort(Card* A, int N){
  int i,j,cnt=0;
  for(i = 0; i < N; i++){
    int mini = i;
    for(j = i; j < N; j++) if(A[j].num < A[mini].num) mini = j;
    cnt += (i==mini?0:1);
    swap(&A[i],&A[mini]);
  }
  return cnt;
}
 
int main(){
  int i,N;
  Card data1[40],data2[40];
  scanf("%d\n",&N);
  for(i = 0; i < N; i++) scanf("%c%c ",&data1[i].suit, &data1[i].num);
  for(i = 0; i < N; i++){
    data2[i] = data1[i];
    data1[i].idx = data2[i].idx = i;
  }
  bubble_sort(data1,N);
  selection_sort(data2,N);
  print(data1,N);
  is_stable(data1,N);
  print(data2,N);
  is_stable(data2,N);
  return 0;
}

Compile Error Logs:

ステータス
Judge: 10/10	C	CPU: 00:00 sec	Memory: 616 KB	Length: 1308 B	2014-04-08 15:00
テストケースの判定結果
Case #	Verdict	CPU Time	Memory	In	Out	Case Name
Case #1	: Accepted	00:00	616	17	48	testcase_00
Case #2	: Accepted	00:00	612	8	26	testcase_01
Case #3	: Accepted	00:00	612	8	26	testcase_02
Case #4	: Accepted	00:00	616	17	44	testcase_03
Case #5	: Accepted	00:00	616	29	72	testcase_04
Case #6	: Accepted	00:00	616	111	234	testcase_05
Case #7	: Accepted	00:00	612	111	234	testcase_06
Case #8	: Accepted	00:00	616	111	234	testcase_07
Case #9	: Accepted	00:00	616	111	234	testcase_08
Case #10	: Accepted	00:00	616	111	234	testcase_09

< prev |		/		| next >	 		
 
Judge Input #  ( | )		Judge Output #  ( | )
 
	  	
 

Aizu Online Judge
follow us on Twitter


About us
Contact


Compiler output:
main.c:74:1: error: unknown type name 'Compile'
   74 | Compile Error Logs:
      | ^~~~~~~
main.c:74:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Logs'
   74 | Compile Error Logs:
      |               ^~~~
main.c:77:81: error: invalid digit "8" in octal constant
   77 | Judge: 10/10    C       CPU: 00:00 sec  Memory: 616 KB  Length: 1308 B  2014-04-08 15:00
      |                                                                                 ^~
main.c:79:6: error: stray '#' in program
   79 | Case #  Verdict CPU Time        Memory  In      Out     Case Name
      |      ^
main.c:80:6: error: stray '#' in program
   80 | Case #1 : Accepted      00:00   616     17      48      testcase_00
      |      ^
main.c:81:6: error: stray '#' in program
   81 | Case #2 : Accepted      00:00   612     8       26      testcase_01
      |      ^
main.c:82:6: error: stray '#' in program
   82 | Case #3 : Accepted      00:00   612     8       26      testcase_02
      |      ^
main.c:83:6: error: stray '#' in program
   83 | Case #4 : Accepted      00:00   616     17      44      testcase_03
      |      ^
main.c:84:6: error: stray '#' in program
   84 | Case #5 : Accepted      00:00   616     29      72      testcase_04
      |      ^
main.c:85:6: error: stray '#' in program
   85 | Case #6 : Accepted      00:00   616     111     234     testcase_05
      |      ^
main.c:86:6: error: stray '#' in program
   86 | Case #7 : Accepted      00:00   612     111     234     testcase_06
      |      ^
main.c:87:6: error: stray '#' in program
   87 | Case #8 : Accepted      00:00   616     111     234     testcase_07
      |      ^
main.c:88:6: error: stray '#' in program
   88 | Case #9 : Accepted      00:00   616     111     234     testcase_08
      |      ^
main.c:89:6: error: stray '#' in program
   89 | Case #10        : Accepted      00:00   616     111     234     testcase_09
      |      ^
main.c:93:13: error: stray '#' in program
   93 | Judge Input #  ( | )            Judge Output #  ( | )
      |             ^
main.c:93:46: error: stray '#' in program
   93 | Judge Input #  ( | )            Judge Output #  ( | )
      |                                              ^