//#include #include using namespace std; struct Pair { int count; char symbol; }; void bubbleSort(Pair array[], int size) { bool needsSorting; int counter = 0; do { needsSorting = false; for (int i = 1; i < size - counter; ++i) { if (array[i].count <= array[i - 1].count) { if (array[i].count == array[i - 1].count) { if (array[i].symbol < array[i - 1].symbol) { swap(array[i - 1], array[i]); } } else { swap(array[i - 1], array[i]); } needsSorting = true; } } ++counter; } while (needsSorting); for (int i = 0; i < size; i++) { } } int main() { ifstream in ("symbol.in"); Pair symbols[5]; for (int i = 0; i < 5; i++) { in >> symbols[i].count; in >> symbols[i].symbol; } bubbleSort(symbols, 5); ofstream out ("symbol.out"); for (int i = 0; i < 5; i++) { for (int j = 0; j < symbols[i].count; j++) { out << symbols[i].symbol; } out << endl; } return 0; }