#include <stdio.h>
 
int main() {
  int n;
  int i,j,e;
  int a[101],b[101];
  int t,minj,flag;
  char c[101],kara,m,d[101],f[4];
  char str[3];
  int sta = 0;
 
  scanf("%d", &n);
 
  for(i=0; i<n; i++) {
 
    scanf("%s",str);
    c[i] = str[0];
    a[i]  = str[1] - '0';
    //    printf("%c %d\n",c[i],a[i]);
    b[i] = a[i];
    d[i] = c[i];
 
  }
 
 
 
  //Bubble Sort
 
  for(i = 0; i<=n-1;i++) {
    for(j = 0; j<=n-1;j++) {
 
      if(a[j] < a[j-1]) {
 
    t = a[j];
    a[j] = a[j-1];
    a[j-1] = t;
 
    m = c[j];
    c[j] = c[j-1];
    c[j-1] = m;
      }
    }
  }
 
  for(i = 0;i<n;i++) {
 
    printf("%c%d",c[i],a[i]);
     
    if(i != n-1) printf(" ");
 
  }
 
  printf("\nStable\n");
 
 
 
 
  // Selsection Sort
 
   
 
  for(i = 0; i<=n-1; i++) {
    minj = i;
    flag = 0;
   
    for(j = i; j<=n-1;j++) {
      if(b[j] < b[minj]) {
    //  printf("%d < %d\n",b[j],b[minj]);
    minj = j;
    //printf("minj = %d\n",b[minj]);
    flag = 1;
      }
    }
 
     
 
    if(flag == 1) {
 
 
      t = b[i];
      b[i] = b[minj];
      b[minj] = t;
 
      m = d[i];
      d[i] = d[minj];
      d[minj] = m;
   
    }
  }
 
    
  for(i=0;i<n;i++) {
     printf("%c%d",d[i],b[i]);
    if(i != n-1) {
      printf(" ");
    }
 
  }
 
 
printf("\n");
flag = 0;
for(j=0;j<n;j++){
 
  //printf("c[%d](%c) = d[%d](%c)\n",j,c[j],j,d[j]);
 
  if(c[j] != d[j]) {
    flag = 1;
    
  }
 } 
 
if(flag == 1) printf("Not stable\n");
 else printf("Stable\n");
 
 return 0;
 
}

Compile Error Logs:

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

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

Aizu Online Judge
follow us on Twitter


About us
ContactSystem InfoThe University of AizuUniv. of Aizu Competitive Programming Club

Tools
WEB Board ToolsVirtual ArenaAPI Reference
Links
ACM/ICPCACM/ICPC Asia JapanACM-ICPC OB/OG Alumni GroupPC KoshienJOI

AtCoderTopCoderCodeForces

Uva Online judgesACM-ICPC Live ArchivePKU JudgeOnline

Best viewed using Firefox, Google ChromeAizu Online Judge Version 1.0 © 2004 - 2016 Univ. of Aizu Competitive Programming Club (ICPCPC), Database Systems Lab. University of Aizu
 
