Language: C++

#include <stdio.h>
#include <iostream>
#include <utility>
using namespace std;

typedef struct {
	char mark;
	int num;
} TRUMP;

void bubbleSort(TRUMP a[], int n);
void selectionSort(TRUMP a[], int n);
void dispTrumpList(const TRUMP trump[], int n);
bool isStable(const TRUMP t1[], const TRUMP t2[], int n);

int main(void)
{	
	int n;
	cin >> n;
	
	TRUMP trump[36], trump1[36], trump2[36];
	for (int i = 0; i < n; i++) {
		cin >> trump[i].mark >> trump[i].num;
	}
	memcpy(trump1, trump, sizeof(trump) * n);
	memcpy(trump2, trump, sizeof(trump) * n);
	
	bubbleSort(trump1, n);
	dispTrumpList(trump1, n);
	if (isState(trump, trump1, n)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	selectionSort(trump2, n);
	dispTrumpList(trump2, n);
	if (isState(trump, trump2, n)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	return 0;
}

void bubbleSort(TRUMP a[], int n)
{
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > i; j--) {
			if (a[j].num < a[j-1].num) {
				swap(a[j], a[j-1]);
			}
		}
	}
}

void selectionSort(TRUMP a[], int n)
{
	int i, j;
	for (i = 0; i < n; i++) {
		int minj = i;
		for (j = i; j < n; j++) {
			if (a[j].num < a[minj].num) {
				minj = j;
			}
		}
		swap(a[i], a[minj]);
	}
}

void dispTrumpList(const TRUMP trump[], int n)
{
	for (int i = 0; i < n; i++) {
		cout << trump[i].mark << trump[i].num;
		if (i < n - 1) cout << " ";
		else cout << endl;
	}
}

bool isStable(const TRUMP t1[], const TRUMP t2[], int n)
{
	char m1[9][4] = '\0';
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			if (m1[t1.num-1][j] == '\0') {
				m1[t1.num-1][j] = t1.mark;
				break;
			}
		}
	}
	
	char m2[9][4] = '\0';
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			if (m2[t2.num-1][j] == '\0') {
				m2[t2.num-1][j] = t2.mark;
				break;
			}
		}
	}
	
	for (int i = 0; i < 9; i++) {
		for (int j = 0; j < 4; j++) {
			if (m1[i][j] != m2[i][j]) return false;
		}
	}
	return true;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: 'memcpy' was not declared in this scope
   25 |         memcpy(trump1, trump, sizeof(trump) * n);
      |         ^~~~~~
a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <utility>
  +++ |+#include <cstring>
    4 | using namespace std;
a.cc:30:13: error: 'isState' was not declared in this scope; did you mean 'isStable'?
   30 |         if (isState(trump, trump1, n)) cout << "Stable" << endl;
      |             ^~~~~~~
      |             isStable
a.cc:35:13: error: 'isState' was not declared in this scope; did you mean 'isStable'?
   35 |         if (isState(trump, trump2, n)) cout << "Stable" << endl;
      |             ^~~~~~~
      |             isStable
a.cc: In function 'bool isStable(const TRUMP*, const TRUMP*, int)':
a.cc:77:25: error: array must be initialized with a brace-enclosed initializer
   77 |         char m1[9][4] = '\0';
      |                         ^~~~
a.cc:80:35: error: request for member 'num' in 't1', which is of pointer type 'const TRUMP*' (maybe you meant to use '->' ?)
   80 |                         if (m1[t1.num-1][j] == '\0') {
      |                                   ^~~
a.cc:81:39: error: request for member 'num' in 't1', which is of pointer type 'const TRUMP*' (maybe you meant to use '->' ?)
   81 |                                 m1[t1.num-1][j] = t1.mark;
      |                                       ^~~
a.cc:81:54: error: request for member 'mark' in 't1', which is of pointer type 'const TRUMP*' (maybe you meant to use '->' ?)
   81 |                                 m1[t1.num-1][j] = t1.mark;
      |                                                      ^~~~
a.cc:87:25: error: array must be initialized with a brace-enclosed initializer
   87 |         char m2[9][4] = '\0';
      |                         ^~~~
a.cc:90:35: error: request for member 'num' in 't2', which is of pointer type 'const TRUMP*' (maybe you meant to use '->' ?)
   90 |                         if (m2[t2.num-1][j] == '\0') {
      |                                   ^~~
a.cc:91:39: error: request for member 'num' in 't2', which is of pointer type 'const TRUMP*' (maybe you meant to use '->' ?)
   91 |                                 m2[t2.num-1][j] = t2.mark;
      |                                       ^~~
a.cc:91:54: error: request for member 'mark' in 't2', which is of pointer type 'const TRUMP*' (maybe you meant to use '->' ?)
   91 |                                 m2[t2.num-1][j] = t2.mark;
      |                                                      ^~~~