Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
??
struct TCard
{
????????char Suit;
????????int?? Num;
????????bool operator==(const TCard& C)const
????????{
????????????????return Suit == C.Suit && Num == C.Num;
????????}
????????bool operator <(const TCard& C)const
????????{
????????????return Num < C.Num;
????????}
????????bool operator <=(const TCard& C)const
????????{
????????????????return Num <= C.Num;
????????}
};
typedef std::vector<TCard> TList;
??
int partition(TList& A, int p, int r)
{
????int i = p - 1;
????for(int j = p; j < r; ++j){
????????if(A[j] <= A[r]){
????????????i = i + 1;
????????????std::swap(A[i],A[j]);
????????}
????}
????std::swap(A[i+1],A[r]);
????return i+1;
}
??
void quickSort(TList& A, int p, int r)
{
????if(p < r){
????????int q = partition(A, p, r);
????????quickSort(A, p, q-1);
????????quickSort(A, q+1, r);
????}
}
TList Input()
{
????????int Count;
????????std::cin >> Count;
????????TList List(Count);
????????for(int i = 0; i < Count; ++i){
????????????????std::cin >> List[i].Suit;
????????????????std::cin >> List[i].Num;
????????}
????????return List;
}
void Output(const TList& List)
{
????????TList::const_iterator It = List.begin();
????????std::cout << It->Suit << " " << It->Num;
????????for(++It; It != List.end(); ++It){
????????????????std::cout << "\n" << It->Suit << " " << It->Num;
????????}
????????std::cout << std::endl;
}
void Check(const TList& List, const TList& Stable)
{
????????if(std::equal(List.begin(), List.end(), Stable.begin())){
????????????????std::cout << "Stable" << std::endl;
????????}else{
????????????????std::cout << "Not stable" << std::endl;
????????}
}
??
int main()
{
????????std::cin.tie(0);
????????std::ios::sync_with_stdio(false);
????????const TList List = Input();
????????TList StableList = List;
????????std::stable_sort(StableList.begin(), StableList.end());
??
????????TList QuickList = List;
????????quickSort(QuickList, 0, QuickList.size() - 1);
????????Check(QuickList, StableList);
????????Output(QuickList);
????????return 0;
}

Compiler output:
a.cc:4:1: error: expected unqualified-id before '?' token
    4 | ??
      | ^
a.cc:22:21: error: 'TCard' was not declared in this scope
   22 | typedef std::vector<TCard> TList;
      |                     ^~~~~
a.cc:22:26: error: template argument 1 is invalid
   22 | typedef std::vector<TCard> TList;
      |                          ^
a.cc:22:26: error: template argument 2 is invalid
a.cc:23:1: error: expected unqualified-id before '?' token
   23 | ??
      | ^
a.cc:36:1: error: expected unqualified-id before '?' token
   36 | ??
      | ^
a.cc: In function 'TList Input()':
a.cc:47:1: error: expected primary-expression before '?' token
   47 | ????????int Count;
      | ^
a.cc:47:2: error: expected primary-expression before '?' token
   47 | ????????int Count;
      |  ^
a.cc:47:3: error: expected primary-expression before '?' token
   47 | ????????int Count;
      |   ^
a.cc:47:4: error: expected primary-expression before '?' token
   47 | ????????int Count;
      |    ^
a.cc:47:5: error: expected primary-expression before '?' token
   47 | ????????int Count;
      |     ^
a.cc:47:6: error: expected primary-expression before '?' token
   47 | ????????int Count;
      |      ^
a.cc:47:7: error: expected primary-expression before '?' token
   47 | ????????int Count;
      |       ^
a.cc:47:8: error: expected primary-expression before '?' token
   47 | ????????int Count;
      |        ^
a.cc:47:9: error: expected primary-expression before 'int'
   47 | ????????int Count;
      |         ^~~
a.cc:47:9: error: expected ':' before 'int'
   47 | ????????int Count;
      |         ^~~
      |         :
a.cc:47:9: error: expected primary-expression before 'int'
   47 | ????????int Count;
      |         ^~~
a.cc:47:9: error: expected ':' before 'int'
   47 | ????????int Count;
      |         ^~~
      |         :
a.cc:47:9: error: expected primary-expression before 'int'
   47 | ????????int Count;
      |         ^~~
a.cc:47:9: error: expected ':' before 'int'
   47 | ????????int Count;
      |         ^~~
      |         :
a.cc:47:9: error: expected primary-expression before 'int'
   47 | ????????int Count;
      |         ^~~
a.cc:47:9: error: expected ':' before 'int'
   47 | ????????int Count;
      |         ^~~
      |         :
a.cc:47:9: error: expected primary-expression before 'int'
   47 | ????????int Count;
      |         ^~~
a.cc:47:9: error: expected ':' before 'int'
   47 | ????????int Count;
      |         ^~~
      |         :
a.cc:47:9: error: expected primary-expression before 'int'
   47 | ????????int Count;
      |         ^~~
a.cc:47:9: error: expected ':' before 'int'
   47 | ????????int Count;
      |         ^~~
      |         :
a.cc:47:9: error: expected primary-expression before 'int'
   47 | ????????int Count;
      |         ^~~
a.cc:47:9: error: expected ':' before 'int'
   47 | ????????int Count;
      |         ^~~
      |         :
a.cc:47:9: error: expected primary-expression before 'int'
   47 | ????????int Count;
      |         ^~~
a.cc:47:9: error: expected ':' before 'int'
   47 | ????????int Count;
      |         ^~~
      |         :
a.cc:47:9: error: expected primary-expression before 'int'
   47 | ????????int Count;
      |         ^~~
a.cc:48:1: error: expected primary-expression before '?' token
   48 | ????????std::cin >> Count;
      | ^
a.cc:48:2: error: expected primary-expression before '?' token
   48 | ????????std::cin >> Count;
      |  ^
a.cc:48:3: error: expected primary-expression before '?' token
   48 | ????????std::cin >> Count;
      |   ^
a.cc:48:4: error: expected primary-expression before '?' token
   48 | ????????std::cin >> Count;
      |    ^
a.cc:48:5: error: expected primary-expression before '?' token
   48 | ????????std::cin >> Count;
      |     ^
a.cc:48:6: error: expected primary-expression before '?' token
   48 | ????????std::cin >> Count;
      |      ^
a.cc:48:7: error: expected primary-expression before '?' token
   48 | ????????std::cin >> Count;
      |       ^
a.cc:48:8: error: expected primary-expression before '?' token
   48 | ????????std::cin >> Count;
      |        ^
a.cc:48:21: error: 'Count' was not declared in this scope
   48 | ????????std::cin >> Count;
      |                     ^~~~~
a.cc:48:26: error: expected ':' before ';' token
   48 | ????????std::cin >> Count;
      |                          ^
      |                          :
a.cc:48:26: error: expected primary-expression before ';' token
a.cc:48:26: error: expected ':' before ';' token
   48 | ????????std::cin >> Count;
      |                          ^
      |                          :
a.cc:48:26: error: expected primary-expression before ';' token
a.cc:48:26: error: expected ':' before ';' token
   48 | ????????std::cin >> Count;
      |                          ^
      |                          :
a.cc:48:26: error: expected primary-expression before ';' token
a.cc:48:26: error: expected ':' before ';' token
   48 | ????????std::cin >> Count;
      |                          ^
      |                          :
a.cc:48:26: error: expected primary-expression before ';' token
a.cc:48:26: error: expected ':' before ';' token
   48 | ????????std::cin >> Count;
      |                          ^
      |                          :
a.cc:48:26: error: expected primary-expression before ';' token
a.cc:48:26: error: expected ':' before ';' token
   48 | ????????std::cin >> Count;
      |                          ^
      |                          :
a.cc:48:26: error: expected primary-expression before ';' token
a.cc:48:26: error: expected ':' before ';' token
   48 | ????????std::cin >> Count;
      |                          ^
      |                          :
a.cc:48:26: error: expected primary-expression before ';' token
a.cc:48:26: error: expected ':' before ';' token
   48 | ????????std::cin >> Count;
      |                          ^
      |                          :
a.cc:48:26: error: expected primary-expression before ';' token
a.cc:49:1: error: expected primary-expression before '?' token
   49 | ????????TList List(Count);
      | ^
a.cc:49:2: error: expected primary-expression before '?' token
   49 | ????????TList List(Count);
      |  ^
a.cc:49:3: error: expected primary-expression before '?' token
   49 | ????????TList List(Count);
      |   ^
a.cc:49:4: error: expected primary-expression before '?' token
   49 | ????????TList List(Count);
      |    ^
a.cc:49:5: error: expected primary-expression before '?' token
   49 | ????????TList List(Count);
      |     ^
a.cc:49:6: error: expected primary-expression before '?' token
   49 | ????????TList List(Count);
      |      ^
a.cc:49:7: error: expected primary-expression before '?' token
   49 | ????????TList List(Count);
      |       ^
a.cc:49:8: error: expected primary-expression before '?' token
   49 | ????????TList List(Count);
      |        ^
a.cc:49:15: error: expected primary-expression before 'List'
   49 | ????????TList List(Count);
      |               ^~~~
a.cc:49:14: error: expected ':' before 'List'
   49 | ????????TList List(Count);
      |              ^~~~~
      |              :
a.cc:49:15: error: 'List' was not declared in this scope; did you mean 'TList'?
   49 | ????????TList List(Count);
      |               ^~~~
      |               TList
a.cc:49:26: error: expected ':' before ';' token
   49 | ????????TList List(Count);
      |                          ^
      |                          :
a.cc:49:26: error: expected primary-expression before ';' token
a.cc:49:26: error: expected ':' before ';' token
   49 | ????????TList List(Count);
      |                          ^
      |                          :
a.cc:49:26: error: expected primary-expression before ';' token
a.cc:49:26: error: expected ':' before ';' token
   49 | ????????TList List(Count);
      |                          ^
      |                          :
a.cc:49:26: error: expected primary-expression before ';' token
a.cc:49:26: error: expected ':' before ';' token
   49 | ????????TList List(Count);
      |                          ^
      |                          :
a.cc:49:26: error: expected primary-expression before ';' token
a.cc:49:26: error: expected ':' before ';' token
   49 | ????????TList List(Count);
      |                          ^
      |                          :
a.cc:49:26: error: expected primary-expression before ';' token
a.cc:49:26: error: expected ':' before ';' token
   49 | ????????TList List(Count);
      |                          ^
      |                          :
a.cc:49:26: error: expected primary-expression before ';' token
a.cc:49:26: error: expected ':' before ';' token
   49 | ????????TList List(Count);
      |                          ^
      |                          :
a.cc:49:26: error: expected primary-expression before ';' token
a.cc:50:1: error: expected primary-expression before '?' token
   50 | ????????for(int i = 0; i < Count; ++i){
      | ^
a.cc:50:2: error: expected primary-expression before '?' token
   50 | ????????for(int i = 0; i < Count; ++i){
      |  ^
a.cc:50:3: error: expected primary-expression before '?' token
   50 | ????????for(int i = 0; i < Count; ++i){
      |   ^
a.cc:50:4: error: expected primary-expression before '?' token
   50 | ????????for(int i = 0; i < Count; ++i){
      |    ^
a.cc:50:5: error: expected primary-expression before '?' token
   50 | ????????for(int i = 0; i < Count; ++i){
      |     ^
a.cc:50:6: error: expected primary-expression before '?' token
   50 | ????????for(int i = 0; i < Count; ++i){
      |      ^
a.cc:50:7: error: expected primary-expression before '?' token
   50 | ????????for(int i = 0; i < Count; ++i){
      |       ^
a.cc:50:8: error: expected primary-expression before '?' token
   50 | ????????for(int i = 0; i < Count; ++i){
      |        ^
a.cc:50:9: error: expected primary-expression before 'for'
   50 | ????????for(int i = 0; i < Count; ++i){
      |         ^~~
a.cc:50:9: error: expected ':' before 'for'
   50 | ????????for(int i = 0; i < Count; ++i){
      |         ^~~
      |         :
a.cc:50:9: error: expected primary-expression before 'for'
   50 | ????????for(int i = 0; i < Count; ++i){
      |         ^~~
a.cc:50:9: error: