fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. int N;
  8. cin >> N;
  9. string C[N];
  10. for(int i = 0; i < N; ++i){
  11. cin >> C[i];
  12. }
  13. // Bubble Sort
  14. for(int i = 0; i < N; ++i){
  15. for(int j = N - 1; j > i; --j){
  16. if(stoi(C[j].at(1)) < stoi(C[j - 1].at(1))){
  17. string str = C[j];
  18. C[j] = C[j - 1];
  19. C[j - 1] = str;
  20. }
  21. }
  22. }
  23. for(int i = 0; i < N; ++i){
  24. if(i != N - 1) printf("%s ", C[i]);
  25. else printf("%s", C[i]);
  26. }
  27. return 0;
  28. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
5
H4 C9 S4 D2 C3
compilation info
prog.cpp: In function 'int main()':
prog.cpp:16:22: error: 'stoi' was not declared in this scope
    if(stoi(C[j].at(1)) < stoi(C[j - 1].at(1))){
                      ^
stdout
Standard output is empty