Language: C++

#include <iostream>
using namespace std;

int main()
{
	int n = 0 , minj = 0, flag = 1, k = 0;
	char a[36][3], b[36][3], temp[3];

	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = 0; i < n; i++)
		strcpy_s(b[i], a[i]);

	while (flag) {
		flag = 0;
		for (int j = n - 1; j > 0; j--) {
			if (b[j][1] < b[j - 1][1]) {
				strcpy_s(temp, b[j - 1]);
				strcpy_s(b[j - 1], b[j]);
				strcpy_s(b[j], temp);
				flag = 1;
			}
		}
	}

	for (int i = 0; i < n - 1; i++)
		cout << b[i] << " ";
	cout << b[n - 1] << endl;

	for (int i = 0; i < n - 1; i++) {
		if (b[i][1] == b[i + 1][1]) {

			int s = 0, t = 0;

			while (strcmp(a[s], b[i]))
				s++;

			while (strcmp(a[t], b[i + 1]))
				t++;

			if (s < t)
				k = 1;
		}
	}

	if (k == 1)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;

	for (int i = 0; i < n; i++)
		strcpy_s(b[i], a[i]);

	for (int i = 0; i < n - 1; i++){

		minj = i;

		for (int j = i + 1; j < n; j++) {
			if (b[j][1] < b[minj][1])
				minj = j;
		}

		if (minj > i) {
			strcpy_s(temp, b[i]);
			strcpy_s(b[i], b[minj]);
			strcpy_s(b[minj], temp);
		}
	}

	for (int i = 0; i < n - 1; i++)
		cout << b[i] << " ";
	cout << b[n - 1] << endl;

	k = 0;

	for (int i = 0; i < n - 1; i++) {
		if (b[i][1] == b[i + 1][1]) {

			int s = 0, t = 0;

			while (strcmp(a[s], b[i]))
				s++;

			while (strcmp(a[t], b[i + 1]))
				t++;

			if (s < t)
				k = 1;
		}
	}

	if (k == 1)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
		
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'strcpy_s' was not declared in this scope
   15 |                 strcpy_s(b[i], a[i]);
      |                 ^~~~~~~~
a.cc:21:33: error: 'strcpy_s' was not declared in this scope
   21 |                                 strcpy_s(temp, b[j - 1]);
      |                                 ^~~~~~~~
a.cc:38:32: error: 'strcmp' was not declared in this scope
   38 |                         while (strcmp(a[s], b[i]))
      |                                ^~~~~~
a.cc:2:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
a.cc:41:32: error: 'strcmp' was not declared in this scope
   41 |                         while (strcmp(a[t], b[i + 1]))
      |                                ^~~~~~
a.cc:41:32: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:55:17: error: 'strcpy_s' was not declared in this scope
   55 |                 strcpy_s(b[i], a[i]);
      |                 ^~~~~~~~
a.cc:67:25: error: 'strcpy_s' was not declared in this scope
   67 |                         strcpy_s(temp, b[i]);
      |                         ^~~~~~~~
a.cc:84:32: error: 'strcmp' was not declared in this scope
   84 |                         while (strcmp(a[s], b[i]))
      |                                ^~~~~~
a.cc:84:32: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:87:32: error: 'strcmp' was not declared in this scope
   87 |                         while (strcmp(a[t], b[i + 1]))
      |                                ^~~~~~
a.cc:87:32: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'