fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. void printFunc(vector<string> a) {
  9. int size = a.size();
  10.  
  11. for (int i = 0; i < size; i++) {
  12. cout << a[i];
  13. if (i != size - 1) cout << "\n";
  14. }
  15.  
  16. }
  17.  
  18. int main() {
  19. cin.tie(NULL);
  20. ios::sync_with_stdio(false);
  21.  
  22. int n;
  23. int k;
  24. cin >> n;
  25. vector<string> mir(n);
  26.  
  27. for (int i = 0; i < n; i++) {
  28. cin >> mir[i];
  29. }
  30. cin >> k;
  31.  
  32. if (k == 1) {
  33. printFunc(mir);
  34. }
  35. else if (k == 2) {
  36. for (int i = 0; i < n; i++) {
  37. reverse(mir[i].begin(), mir[i].end());
  38. }
  39. printFunc(mir);
  40. }
  41. else {
  42. int cnt = 0;
  43. while (cnt <= n / 2) {
  44. string temp = mir[cnt];
  45. mir[cnt] = mir[n - cnt - 1];
  46. mir[n - cnt - 1] = temp;
  47. cnt++;
  48. }
  49. printFunc(mir);
  50. }
  51.  
  52. }
Success #stdin #stdout 0s 15240KB
stdin
2
OO
AA
3
stdout
OO
AA