Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int x = 0;
  8.  
  9. cin >> x;
  10.  
  11. int** arr;
  12.  
  13. arr = new int*[x];
  14. for (int i = 0; i < x; i++)
  15. {
  16. arr[i] = new int[x];
  17.  
  18. }
  19.  
  20. for (int i = 0; i < x; i++)
  21. {
  22. for (int j = 0; j < x; j++)
  23. {
  24. cin >> arr[i][j];
  25. }
  26. }
  27.  
  28. /* for (int i = 0; i < x; i++)
  29. {
  30. for (int j = 0; j < x; j++)
  31. {
  32. cout << arr[i][j] << " ";
  33. }
  34. cout << "\n";
  35. }
  36. */ cout << "\n";
  37.  
  38. int tmp = 0;
  39.  
  40. for (int i = 1; i < x; i++)
  41. {
  42. for (int j = 0; j < x - 1; j++)
  43. {
  44. tmp = arr[i][j];
  45. arr[i][j] = arr[j][i];
  46. arr[j][i] = tmp;
  47. }
  48. }
  49.  
  50. for (int i = 0; i < x; i++)
  51. {
  52. for (int j = 0; j < x; j++)
  53. {
  54. cout << arr[i][j] << " ";
  55. }
  56. cout << "\n";
  57. }
  58.  
  59. for (int i = 0; i < x; i++)
  60. {
  61. delete arr[i];
  62. }
  63. delete arr;
  64.  
  65.  
  66.  
  67. system("pause");
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement