Language: C++

#include <iostream>
#include <string>
#include <vector>

#define rep(i,s,N) for(int i=s;i<N;++i) 

struct Card {
	char suit,
	char value;
	int index;
}

template<typename T>
void swap(T& a, T& b) {
	T t = a;
	a = b;
	b = t;
}

void print(std::vector<Card> v) {
	for(int i=0;i<v.size();++i){
		if (i==0) std::cout << v[i].suit << v[i].value;
		else std::cout << " " << v[i].suit << v[i].value;
	}
}

template<typename U>
void sort_bubble(std::vector<U> &x) {
	// init
	for (int i=0; i<x.size(); ++i) ix[i] = i;
	// sort
	for (int i=0; i<x.size(); ++i) {
		for (int j=x.size()-1; j>i; --j) {
			if (x[j] < x[j-1]) {
				swap(x[j], x[j-1]);
			}
		}
	}
}

template<typename T>
void sort_selection(std::vector<T> &x){
	// init
	for (int i=0; i<x.size(); ++i) ix[i] = i;
	// sort
	for (int i=0; i<x.size(); ++i) {
		int min_index = i;
		for (int j=i+1; j<x.size(); ++j) {
			if (x[j] < x[min_index]) min_index = j; 
		}
		if (x[i] == x[min_index]) {
			continue;
		}
		swap(x[i], x[min_index]);
	}
}

template<typename T>
bool check_stability(const std::vector<T> &x) {
	for (int i=1; i<x.size(); ++i) {
		if (x[i-1].value == x[i].value
		    &&  x[i-1].index > x[i].index) {
			return false;
		}
	}
	return true;
}

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<Card> C(N);
	rep(i,0,N) {
		cin >> C[i].suit >> C[i].value;
		C[i].index = i;
	}
	vector<Card> C1(C), C2(C);
	
	// sort
	sort_bubble(C1);
	sort_selection(C2);

	print(C1);
	cout << check_stability(C1) ? "Stable" : "Not stable" << endl;
	print(C2);
	cout << check_stability(C2) ? "Stable" : "Not stable" << endl;

	return 0;
}




Compiler output:
a.cc:9:9: error: expected unqualified-id before 'char'
    9 |         char value;
      |         ^~~~
a.cc:11:2: error: expected ';' after struct definition
   11 | }
      |  ^
      |  ;
a.cc: In function 'void print(std::vector<Card>)':
a.cc:22:58: error: '__gnu_cxx::__alloc_traits<std::allocator<Card>, Card>::value_type' {aka 'struct Card'} has no member named 'value'
   22 |                 if (i==0) std::cout << v[i].suit << v[i].value;
      |                                                          ^~~~~
a.cc:23:60: error: '__gnu_cxx::__alloc_traits<std::allocator<Card>, Card>::value_type' {aka 'struct Card'} has no member named 'value'
   23 |                 else std::cout << " " << v[i].suit << v[i].value;
      |                                                            ^~~~~
a.cc: In function 'void sort_bubble(std::vector<U>&)':
a.cc:30:40: error: 'ix' was not declared in this scope; did you mean 'i'?
   30 |         for (int i=0; i<x.size(); ++i) ix[i] = i;
      |                                        ^~
      |                                        i
a.cc: In function 'void sort_selection(std::vector<U>&)':
a.cc:44:40: error: 'ix' was not declared in this scope; did you mean 'i'?
   44 |         for (int i=0; i<x.size(); ++i) ix[i] = i;
      |                                        ^~
      |                                        i
a.cc: In function 'int main()':
a.cc:76:42: error: '__gnu_cxx::__alloc_traits<std::allocator<Card>, Card>::value_type' {aka 'struct Card'} has no member named 'value'
   76 |                 cin >> C[i].suit >> C[i].value;
      |                                          ^~~~~
a.cc:86:63: error: invalid operands of types 'const char [11]' and '<unresolved overloaded function type>' to binary 'operator<<'
   86 |         cout << check_stability(C1) ? "Stable" : "Not stable" << endl;
      |                                                  ~~~~~~~~~~~~~^~~~~~~
a.cc:88:63: error: invalid operands of types 'const char [11]' and '<unresolved overloaded function type>' to binary 'operator<<'
   88 |         cout << check_stability(C2) ? "Stable" : "Not stable" << endl;
      |                                                  ~~~~~~~~~~~~~^~~~~~~
a.cc: In instantiation of 'void sort_bubble(std::vector<U>&) [with U = Card]':
a.cc:82:13:   required from here
   82 |         sort_bubble(C1);
      |         ~~~~~~~~~~~^~~~
a.cc:34:34: error: no match for 'operator<' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<Card>, Card>::value_type' {aka 'Card'} and '__gnu_cxx::__alloc_traits<std::allocator<Card>, Card>::value_type' {aka 'Card'})
   34 |                         if (x[j] < x[j-1]) {
      |                             ~~~~~^~~~
a.cc: In instantiation of 'void sort_selection(std::vector<U>&) [with T = Card]':
a.cc:83:16:   required from here
   83 |         sort_selection(C2);
      |         ~~~~~~~~~~~~~~^~~~
a.cc:49:34: error: no match for 'operator<' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<Card>, Card>::value_type' {aka 'Card'} and '__gnu_cxx::__alloc_traits<std::allocator<Card>, Card>::value_type' {aka 'Card'})
   49 |                         if (x[j] < x[min_index]) min_index = j;
      |                             ~~~~~^~~~
a.cc:51:26: error: no match for 'operator==' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<Card>, Card>::value_type' {aka 'Card'} and '__gnu_cxx::__alloc_traits<std::allocator<Card>, Card>::value_type' {aka 'Card'})
   51 |                 if (x[i] == x[min_index]) {
      |                     ~~~~~^~~~~
a.cc: In instantiation of 'bool check_stability(const std::vector<U>&) [with T = Card]':
a.cc:86:25:   required from here
   86 |         cout << check_stability(C1) ? "Stable" : "Not stable" << endl;
      |                 ~~~~~~~~~~~~~~~^~~~
a.cc:61:28: error: 'const __gnu_cxx::__alloc_traits<std::allocator<Card>, Card>::value_type' {aka 'const struct Card'} has no member named 'value'
   61 |                 if (x[i-1].value == x[i].value
      |                     ~~~~~~~^~~~~
a.cc:61:42: error: 'const __gnu_cxx::__alloc_traits<std::allocator<Card>, Card>::value_type' {aka 'const struct Card'} has no member named 'value'
   61 |                 if (x[i-1].value == x[i].value
      |                                     ~~~~~^~~~~