#include #include using namespace std; void swap_if(string & x, string & y) { if (x > y) { string t = x; x = y; y = t; } } void sort(string A[], int N) { for (int line = N-1; line >= 1; line -= 1) for (int firstvar = 0; firstvar < line; firstvar += 1) swap_if(A[firstvar], A[firstvar + 1]); } int main() { cout << "How many strings have you got? "; int N; cin >> N; string * A = new string[N]; for (int i = 0; i < N; i += 1) { cout << "A[" << i << "] = "; cin >> A[i]; } sort(A, N); cout << "\n"; for (int i = 0; i < N; i += 1) cout << "A[" << i << "] = " << A[i] << "\n"; delete [] A; }