Language: C


    printf("%c%c",A[i].mark,A[i].value);
  }
  printf("\n");
}

 int table(struct Number B[], struct Number C[], int n){
   int i;
   for(i=0; i<n; i++){
     if(B[i].mark != C[i].mark)return 0;
   }
   return 1;
 }
int main()
{
  int i,j,n;
  struct Number B[NM],C[NM];

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf(" %c%c",&B[i].mark,&B[i].value);
  }
  for(i=0; i<n; i++){
    C[i]=B[i];
  }

  bubble(B,n);
  selections(C,n);

  print(B,n);
  printf("Stable\n");
  print(C,n);
  if(table(B,C,n)==1){
    printf("Stable\n");
  }
  else printf("Not stable\n");

  return 0;
}
#include<stdio.h>
#include<stdlib.h>
 
#define NMIN 1
#define NMAX 36
 
struct Number{
char mark;
char value;  
};
 
 
void bubble(struct Number A[],int N){
  int i,j;
 struct Number t;
  for(i=0;i<N;i++){
for(j=N-1;j>=i;j--){
  if(A[j].value<A[j-1].value){
    t=A[j];
    A[j]=A[j-1];
    A[j-1]=t;
  }
}    
  }
}
 
void selections(struct Number A[],int N){
  int i,j,minj;
 struct Number t;
  for(i=0;i<N;i++){
minj=i; 
for(j=i;j<N;j++){
  if(A[j].value<A[minj].value) minj=j;
}
t=A[i];
A[i]=A[minj];
A[minj]=t;
  }
}
 
void print(struct Number A[],int N){
int i;
for(i=0;i<N;i++){
  if(i>0) printf(" ");
  printf("%c%c",A[i].mark,A[i].value);
}
 printf("\n");
}
 
int isStable(struct Number N1[],struct Number N2[],int N){
int i;
  for(i=0;i<N;i++){
    if(N1[i].mark != N2[i].mark) return 0;
  }
  return 1;
}
 
 
 
int main(){
int N,i,j;
struct Number N1[NMAX],N2[NMAX];
char ch;
scanf("%d",&N);
if(N<NMIN||N>NMAX) exit(1);
for(i=0;i<N;i++){
  scanf(" %c%c",&N1[i].mark,&N1[i].value);
}
for(i=0;i<N;i++){
N2[i]=N1[i];
}
bubble(N1,N);
selections(N2,N);
 
print(N1,N);
printf("Stable\n");
print(N2,N);
if(isStable(N1,N2,N)==1){
  printf("Stable\n");
}
else{
  printf("Not stable\n");
}
  return 0;
}#include<stdio.h>
#include<stdlib.h>
 
#define NMIN 1
#define NMAX 36
 
struct Number{
char mark;
char value;  
};
 
 
void bubble(struct Number A[],int N){
  int i,j;
 struct Number t;
  for(i=0;i<N;i++){
for(j=N-1;j>=i;j--){
  if(A[j].value<A[j-1].value){
    t=A[j];
    A[j]=A[j-1];
    A[j-1]=t;
  }
}    
  }
}
 
void selections(struct Number A[],int N){
  int i,j,minj;
 struct Number t;
  for(i=0;i<N;i++){
minj=i; 
for(j=i;j<N;j++){
  if(A[j].value<A[minj].value) minj=j;
}
t=A[i];
A[i]=A[minj];
A[minj]=t;
  }
}
 
void print(struct Number A[],int N){
int i;
for(i=0;i<N;i++){
  if(i>0) printf(" ");
  printf("%c%c",A[i].mark,A[i].value);
}
 printf("\n");
}
 
int isStable(struct Number N1[],struct Number N2[],int N){
int i;
  for(i=0;i<N;i++){
    if(N1[i].mark != N2[i].mark) return 0;
  }
  return 1;
}
 
 
 
int main(){
int N,i,j;
struct Number N1[NMAX],N2[NMAX];
char ch;
scanf("%d",&N);
if(N<NMIN||N>NMAX) exit(1);
for(i=0;i<N;i++){
  scanf(" %c%c",&N1[i].mark,&N1[i].value);
}
for(i=0;i<N;i++){
N2[i]=N1[i];
}
bubble(N1,N);
selections(N2,N);
 
print(N1,N);
printf("Stable\n");
print(N2,N);
if(isStable(N1,N2,N)==1){
  printf("Stable\n");
}
else{
  printf("Not stable\n");
}
  return 0;
}



Compiler output:
main.c:2:12: error: expected declaration specifiers or '...' before string constant
    2 |     printf("%c%c",A[i].mark,A[i].value);
      |            ^~~~~~
main.c:2:19: error: unknown type name 'A'
    2 |     printf("%c%c",A[i].mark,A[i].value);
      |                   ^
main.c:2:29: error: unknown type name 'A'
    2 |     printf("%c%c",A[i].mark,A[i].value);
      |                             ^
main.c:3:3: error: expected identifier or '(' before '}' token
    3 |   }
      |   ^
main.c:4:10: error: expected declaration specifiers or '...' before string constant
    4 |   printf("\n");
      |          ^~~~
main.c:5:1: error: expected identifier or '(' before '}' token
    5 | }
      | ^
main.c:7:26: error: array type has incomplete element type 'struct Number'
    7 |  int table(struct Number B[], struct Number C[], int n){
      |                          ^
main.c:7:45: error: array type has incomplete element type 'struct Number'
    7 |  int table(struct Number B[], struct Number C[], int n){
      |                                             ^
main.c:7:19: warning: 'struct Number' declared inside parameter list will not be visible outside of this definition or declaration
    7 |  int table(struct Number B[], struct Number C[], int n){
      |                   ^~~~~~
main.c: In function 'main':
main.c:17:19: error: 'NM' undeclared (first use in this function)
   17 |   struct Number B[NM],C[NM];
      |                   ^~
main.c:17:19: note: each undeclared identifier is reported only once for each function it appears in
main.c:19:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   19 |   scanf("%d",&n);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | 
main.c:19:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   19 |   scanf("%d",&n);
      |   ^~~~~
main.c:19:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:28:3: error: implicit declaration of function 'bubble' [-Wimplicit-function-declaration]
   28 |   bubble(B,n);
      |   ^~~~~~
main.c:29:3: error: implicit declaration of function 'selections' [-Wimplicit-function-declaration]
   29 |   selections(C,n);
      |   ^~~~~~~~~~
main.c:31:3: error: implicit declaration of function 'print' [-Wimplicit-function-declaration]
   31 |   print(B,n);
      |   ^~~~~
main.c:32:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   32 |   printf("Stable\n");
      |   ^~~~~~
main.c:32:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:32:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:32:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:34:12: error: type of formal parameter 1 is incomplete
   34 |   if(table(B,C,n)==1){
      |            ^
main.c:34:14: error: type of formal parameter 2 is incomplete
   34 |   if(table(B,C,n)==1){
      |              ^
main.c: At top level:
main.c:53:6: warning: conflicting types for 'bubble'; have 'void(struct Number *, int)'
   53 | void bubble(struct Number A[],int N){
      |      ^~~~~~
main.c:28:3: note: previous implicit declaration of 'bubble' with type 'void(struct Number *, int)'
   28 |   bubble(B,n);
      |   ^~~~~~
main.c:67:6: warning: conflicting types for 'selections'; have 'void(struct Number *, int)'
   67 | void selections(struct Number A[],int N){
      |      ^~~~~~~~~~
main.c:29:3: note: previous implicit declaration of 'selections' with type 'void(struct Number *, int)'
   29 |   selections(C,n);
      |   ^~~~~~~~~~
main.c:81:6: warning: conflicting types for 'print'; have 'void(struct Number *, int)'
   81 | void print(struct Number A[],int N){
      |      ^~~~~
main.c:31:3: note: previous implicit declaration of 'print' with type 'void(struct Number *, int)'
   31 |   print(B,n);
      |   ^~~~~
main.c:100:5: error: redefinition of 'main'
  100 | int main(){
      |     ^~~~
main.c:14:5: note: previous definition of 'main' with type 'int()'
   14 | int main()
      |     ^~~~
main.c:125:2: error: stray '#' in program
  125 | }#include<stdio.h>
      |  ^
main.c:125:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
  125 | }#include<stdio.h>
      |          ^
main.c:137:6: error: redefinition of 'bubble'
  137 | void bubble(struct Number A[],int N){
      |      ^~~~~~
main.c:53:6: note: previous definition of 'bubble' with type 'void(struct Number *, int)'
   53 | void bubble(struct Number A[],int N){
      |      ^~~~~~
main.c:151:6: error: redefinition of 'selections'
  151 | void selections(struct Number A[],int N){
      |      ^~~~~~~~~~
main.c:67:6: note: previous definition of 'selections' with type 'void(struct Number *, int)'
   67 | void selections(struct Number A[],int N){
      |      ^~~~~~~~~~
main.c:165:6: error: redefinition of 'print'
  165 | void print(struct Number A[],int N){
      |      ^~~~~
main.c:81:6: note: previous definition of 'print' with type 'void(struct Number *, int)'
   81 | void print(struct Number A[],int N){
      |      ^~~~~
main.c:174:5: error: redefinition of 'isStable'
  174 | int isStable(struct Number N1[],struct Number N2[],int N){
      |     ^~~~~~~~
main.c:90:5: note: previous definition of 'isStable' with type 'int(struct Number *, struct Number *, int)'
   90 | int isStable(struct Number N1[],struct Number N2[],int N){
      |     ^~~~~~~~
main.c:184:5: error: redefinition of 'main'
  184 | int main(){
      |     ^~~~
main.c:14:5: note: previous definition of 'main' with type 'int()'
   14 | int main()
      |     ^~~~