Advertisement
awsmpshk

Untitled

Dec 26th, 2019
130
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int n, m;
  8. cin >> n >> m;
  9. int** a = new int* [n];
  10. for (int i = 0; i < n; ++i) {
  11. a[i] = new int[m];
  12. for (int j = 0; j < m; ++j) {
  13. cin >> a[i][j];
  14. }
  15. }
  16. for (int j = 0; j < m; ++j) {
  17. for (int i = 0; i < n; ++i) {
  18. int t = a[i][j];
  19. a[i][j] = a[i][m - (j + 1)];
  20. a[i][m - (j + 1)] = t;
  21. }
  22. }
  23. for (int i = 0; i < n; ++i) {
  24. for (int j = 0; j < m; ++j) {
  25. cout << a[i][j] << " ";
  26. }
  27. cout << endl;
  28. delete[] a[i];
  29. }
  30. delete[] a;
  31. return 0;
  32. }
Advertisement
RAW Paste Data Copied
Advertisement