Problem p02261 (C++)

Buggy submission (status: Runtime Error):
#include <cstdint>
#include <fstream>
#include <iostream>
#include <string>

typedef std::uint_least16_t USI;
typedef std::int_least16_t SSI;
typedef std::uint_least32_t ULI; // 10^9
typedef std::int_least32_t SLI;
typedef std::uint_least64_t ULLI;
typedef std::int_least64_t SLLI;

using namespace std;

struct Card {
  char S;
  USI N;
};

string StableCheck[9];

void Swap(Card pC[], int a, int b) {
  Card temp = pC[a];
  pC[a] = pC[b];
  pC[b] = temp;
}

void CheckStable(Card C[], int N, string str[]) {
  for (int i = 0; i < N; i++) {
    str[C[i].N - 1] += C[i].S;
  }
}

void PrintOutStable(string str[]) {
  bool IsStableSort = true;

  for (int i = 0; i < 9; i++) {
    if (str[i] != StableCheck[i]) {
      IsStableSort = false;
      break;
    }
  }

  if (IsStableSort) {
    cout << "\nStable\n";
  } else {
    cout << "\nNot stable\n";
  }
}

void PrintOut(Card pC[], int N) {
  for (int i = 0; i < N; i++) {
    if (i != 0)
      cout << " ";
    cout << pC[i].S << pC[i].N;
  }
}

void BubbleSort(const Card pC[], int N) {
  Card C[36];
  bool IsStable = true;

  for (int i = 0; i < N; i++) {
    C[i] = pC[i];
  }

  for (int i = 0; i < N; i++) {
    for (int j = N - 1; j > i; j--) {
      if (C[j].N < C[j - 1].N) {
        Swap(C, j, j - 1);
      }
    }
  }

  PrintOut(C, N);

  string strSelectionSort[9];
  CheckStable(C, N, strSelectionSort);
  PrintOutStable(strSelectionSort);
}

void SelectionSort(const Card pC[], int N) {
  Card C[36];

  for (int i = 0; i < N; i++) {
    C[i] = pC[i];
  }

  for (int i = 0; i < N; i++) {
    int minj = i;
    for (int j = i; j < N; j++) {
      if (C[j].N < C[minj].N) {
        minj = j;
      }
    }
    if (i != minj) {
      Swap(C, i, minj);
    }
  }

  PrintOut(C, N);

  string strSelectionSort[9];
  CheckStable(C, N, strSelectionSort);
  PrintOutStable(strSelectionSort);
}

int main() {
  // input from txt
  std::ifstream in(R"(C:\Temp\input.txt)");
  std::cin.rdbuf(in.rdbuf());

  int N;
  cin >> N;
  cin.clear();
  cin.ignore();

  Card C[36];
  string str;

  for (int i = 0; i < N; i++) {
    cin >> str;
    C[i].S = str[0];
    C[i].N = str[1] - '0';
  }

  CheckStable(C, N, StableCheck);

  BubbleSort(C, N);
  SelectionSort(C, N);

  return 0;
}

Fixed submission:
#include <cstdint>
#include <fstream>
#include <iostream>
#include <string>

typedef std::uint_least16_t USI;
typedef std::int_least16_t SSI;
typedef std::uint_least32_t ULI; // 10^9
typedef std::int_least32_t SLI;
typedef std::uint_least64_t ULLI;
typedef std::int_least64_t SLLI;

using namespace std;

struct Card {
  char S;
  USI N;
};

string StableCheck[9];

void Swap(Card pC[], int a, int b) {
  Card temp = pC[a];
  pC[a] = pC[b];
  pC[b] = temp;
}

void CheckStable(Card C[], int N, string str[]) {
  for (int i = 0; i < N; i++) {
    str[C[i].N - 1] += C[i].S;
  }
}

void PrintOutStable(string str[]) {
  bool IsStableSort = true;

  for (int i = 0; i < 9; i++) {
    if (str[i] != StableCheck[i]) {
      IsStableSort = false;
      break;
    }
  }

  if (IsStableSort) {
    cout << "\nStable\n";
  } else {
    cout << "\nNot stable\n";
  }
}

void PrintOut(Card pC[], int N) {
  for (int i = 0; i < N; i++) {
    if (i != 0)
      cout << " ";
    cout << pC[i].S << pC[i].N;
  }
}

void BubbleSort(const Card pC[], int N) {
  Card C[36];
  bool IsStable = true;

  for (int i = 0; i < N; i++) {
    C[i] = pC[i];
  }

  for (int i = 0; i < N; i++) {
    for (int j = N - 1; j > i; j--) {
      if (C[j].N < C[j - 1].N) {
        Swap(C, j, j - 1);
      }
    }
  }

  PrintOut(C, N);

  string strSelectionSort[9];
  CheckStable(C, N, strSelectionSort);
  PrintOutStable(strSelectionSort);
}

void SelectionSort(const Card pC[], int N) {
  Card C[36];

  for (int i = 0; i < N; i++) {
    C[i] = pC[i];
  }

  for (int i = 0; i < N; i++) {
    int minj = i;
    for (int j = i; j < N; j++) {
      if (C[j].N < C[minj].N) {
        minj = j;
      }
    }
    if (i != minj) {
      Swap(C, i, minj);
    }
  }

  PrintOut(C, N);

  string strSelectionSort[9];
  CheckStable(C, N, strSelectionSort);
  PrintOutStable(strSelectionSort);
}

int main() {
  int N;
  cin >> N;
  cin.clear();
  cin.ignore();

  Card C[36];
  string str;

  for (int i = 0; i < N; i++) {
    cin >> str;
    C[i].S = str[0];
    C[i].N = str[1] - '0';
  }

  CheckStable(C, N, StableCheck);

  BubbleSort(C, N);
  SelectionSort(C, N);

  return 0;
}