fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7. constexpr int STATE_SIZE = 2;
  8. constexpr int CITY_SIZE = 3;
  9.  
  10. std::string data[STATE_SIZE/* 2 */][CITY_SIZE /* 3 */] =
  11. {
  12. {"ABC", "XYZ", "PQR"},
  13. {"UHA", "ADC", "GSF"}
  14. };
  15. std::string states[STATE_SIZE] = {"AAA", "BBB"};
  16.  
  17. for (int i = 0; i != STATE_SIZE; ++i) {
  18. std::sort(data[i], data[i] + CITY_SIZE);
  19. }
  20.  
  21. for (int i = 0; i != STATE_SIZE; ++i) {
  22. std::cout << states[i] << std::endl;
  23. for (int j = 0; j != CITY_SIZE; ++j) {
  24. std::cout << " " << data[i][j] << std::endl;
  25. }
  26. }
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
AAA
    ABC
    PQR
    XYZ
BBB
    ADC
    GSF
    UHA