Language: C++


include <cstdio>
 
struct Card{ char suit, value; };
 
void bubble(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        for (int j = N - 1; j > i; j--){
            if (A[j].value < A[j - 1].value){
                Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
            }
        }
    }
}
 
void selection(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        int minj = i;
        for (int j = i; j < N; j++){
            if (A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}
 
void print(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        if (i > 0) putchar(' ');
        printf("%c%d", A[i].suit, A[i].value);
    }
    putchar('\n');
}
 
//?????????????????????¨?????????????????????????????????
int isStable(struct Card C1[], struct Card C2[], int N){
    for (int i = 0; i < N; i++){
        if (C1[i].suit != C2[i].suit) return 0; // stable
    }
    return 1; //not stable
}
 
int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
 
    scanf("%d", &N);
    for (int i = 0; i < N; i++){
        scanf("%*c%c%d", &C1[i].suit, &C1[i].value);
    }
 
    for (int i = 0; i < N; i++)C2[i] = C1[i];
 
    bubble(C1, N);
    selection(C2, N);
 
    print(C1, N);
    puts("Stable");
    print(C2, N);
    if (isStable(C1, C2, N)){
        puts("Stable");
    }
    else{
        puts("Not stable");
    }
 
    return 0;
     
}
 
 

Compiler output:
a.cc:2:1: error: 'include' does not name a type
    2 | include <cstdio>
      | ^~~~~~~
a.cc: In function 'void bubble(Card*, int)':
a.cc:9:20: error: invalid use of incomplete type 'struct Card'
    9 |             if (A[j].value < A[j - 1].value){
      |                    ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:9:20: error: invalid use of incomplete type 'struct Card'
    9 |             if (A[j].value < A[j - 1].value){
      |                 ~~~^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:9:37: error: invalid use of incomplete type 'struct Card'
    9 |             if (A[j].value < A[j - 1].value){
      |                                     ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
cc1plus: error: invalid use of incomplete type 'struct Card'
a.cc:6:20: note: forward declaration of 'struct Card'
a.cc:9:37: error: invalid use of incomplete type 'struct Card'
    9 |             if (A[j].value < A[j - 1].value){
      |                              ~~~~~~~^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:10:22: error: variable 'Card t' has initializer but incomplete type
   10 |                 Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      |                      ^
a.cc:10:29: error: invalid use of incomplete type 'struct Card'
   10 |                 Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      |                             ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:10:35: error: invalid use of incomplete type 'struct Card'
   10 |                 Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      |                                   ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:10:46: error: invalid use of incomplete type 'struct Card'
   10 |                 Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      |                                              ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
cc1plus: error: invalid use of incomplete type 'struct Card'
a.cc:6:20: note: forward declaration of 'struct Card'
a.cc:10:35: error: invalid use of incomplete type 'struct Card'
   10 |                 Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      |                                ~~~^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:10:56: error: invalid use of incomplete type 'struct Card'
   10 |                 Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      |                                                        ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
cc1plus: error: invalid use of incomplete type 'struct Card'
a.cc:6:20: note: forward declaration of 'struct Card'
a.cc: In function 'void selection(Card*, int)':
a.cc:20:20: error: invalid use of incomplete type 'struct Card'
   20 |             if (A[j].value < A[minj].value) minj = j;
      |                    ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:20:20: error: invalid use of incomplete type 'struct Card'
   20 |             if (A[j].value < A[minj].value) minj = j;
      |                 ~~~^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:20:36: error: invalid use of incomplete type 'struct Card'
   20 |             if (A[j].value < A[minj].value) minj = j;
      |                                    ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:20:36: error: invalid use of incomplete type 'struct Card'
   20 |             if (A[j].value < A[minj].value) minj = j;
      |                              ~~~~~~^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:22:14: error: variable 'Card t' has initializer but incomplete type
   22 |         Card t = A[i]; A[i] = A[minj]; A[minj] = t;
      |              ^
a.cc:22:21: error: invalid use of incomplete type 'struct Card'
   22 |         Card t = A[i]; A[i] = A[minj]; A[minj] = t;
      |                     ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:22:27: error: invalid use of incomplete type 'struct Card'
   22 |         Card t = A[i]; A[i] = A[minj]; A[minj] = t;
      |                           ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:22:37: error: invalid use of incomplete type 'struct Card'
   22 |         Card t = A[i]; A[i] = A[minj]; A[minj] = t;
      |                                     ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:22:27: error: invalid use of incomplete type 'struct Card'
   22 |         Card t = A[i]; A[i] = A[minj]; A[minj] = t;
      |                        ~~~^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:22:46: error: invalid use of incomplete type 'struct Card'
   22 |         Card t = A[i]; A[i] = A[minj]; A[minj] = t;
      |                                              ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc: In function 'void print(Card*, int)':
a.cc:28:20: error: 'putchar' was not declared in this scope; did you mean 'char'?
   28 |         if (i > 0) putchar(' ');
      |                    ^~~~~~~
      |                    char
a.cc:29:27: error: invalid use of incomplete type 'struct Card'
   29 |         printf("%c%d", A[i].suit, A[i].value);
      |                           ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:29:27: error: invalid use of incomplete type 'struct Card'
   29 |         printf("%c%d", A[i].suit, A[i].value);
      |                        ~~~^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:29:38: error: invalid use of incomplete type 'struct Card'
   29 |         printf("%c%d", A[i].suit, A[i].value);
      |                                      ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:29:38: error: invalid use of incomplete type 'struct Card'
   29 |         printf("%c%d", A[i].suit, A[i].value);
      |                                   ~~~^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:29:9: error: 'printf' was not declared in this scope
   29 |         printf("%c%d", A[i].suit, A[i].value);
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | 
a.cc:31:5: error: 'putchar' was not declared in this scope; did you mean 'char'?
   31 |     putchar('\n');
      |     ^~~~~~~
      |     char
a.cc: In function 'int isStable(Card*, Card*, int)':
a.cc:37:17: error: invalid use of incomplete type 'struct Card'
   37 |         if (C1[i].suit != C2[i].suit) return 0; // stable
      |                 ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:37:17: error: invalid use of incomplete type 'struct Card'
   37 |         if (C1[i].suit != C2[i].suit) return 0; // stable
      |             ~~~~^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:37:31: error: invalid use of incomplete type 'struct Card'
   37 |         if (C1[i].suit != C2[i].suit) return 0; // stable
      |                               ^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc:37:31: error: invalid use of incomplete type 'struct Card'
   37 |         if (C1[i].suit != C2[i].suit) return 0; // stable
      |                           ~~~~^
a.cc:6:20: note: forward declaration of 'struct Card'
    6 | void bubble(struct Card A[], int N){
      |                    ^~~~
a.cc: In function 'int main()':
a.cc:43:10: error: elements of array 'Card C1 [100]' have incomplete type
   43 |     Card C1[100], C2[100];
      |          ^~
a.cc:43:10: error: storage size of 'C1' isn't known
a.cc:43:19: error: elements of array 'Card C2 [100]' have incomplete type
   43 |     Card C1[100], C2[100];
      |                   ^~
a.cc:43:19: error: storage size of 'C2' isn't known
a.cc:47:5: error: 'scanf' was not declared in this scope
   47 |     scanf("%d", &N);
      |     ^~~~~
a.cc:58:5: error: 'puts' was not declared in this scope
   58 |     puts("Stable");
      |     ^~~~