fork download
  1. #include <ctime>
  2. #include <cstdlib>
  3. #include <iostream>
  4. using namespace std;
  5. int main()
  6. {
  7. //setlocale(LC_ALL, "russian");
  8. srand((time(0)));
  9. int n;
  10. cout << "введите размер массива: ";
  11. cin >> n;
  12. int** A = new int* [n];
  13.  
  14. cout << endl;
  15.  
  16. for (int i = 0; i < n; i++)
  17. {
  18. A[i] = new int[n];
  19. for (int j = 0; j < n; j++) {
  20. A[i][j] = rand() % 100;
  21. cout << A[i][j] << " ";
  22.  
  23. }
  24. cout << endl;
  25. }
  26. cout << endl << endl;
  27.  
  28. for (int i = 0; i < n-1; i+=2)
  29. {
  30. int * tmp = A[i];
  31. A[i] = A[i+1];
  32. A[i+1] = tmp;
  33. }
  34.  
  35. for (int i = 0; i < n; i++)
  36. {
  37. for (int j = 0; j < n; j++) {
  38. cout << A[i][j] << " ";
  39. }
  40. cout << endl;
  41. }
  42.  
  43.  
  44. for (int i = 0; i < n; i++)
  45. {
  46. delete A[i];
  47. }
  48. delete[] A;
  49. return 0;
  50. }
  51.  
Success #stdin #stdout 0s 4652KB
stdin
8
stdout
введите размер массива: 
49 10 74 64 79 66 44 49 
55 31 3 50 16 84 63 83 
32 16 36 50 39 95 31 22 
34 70 94 7 15 57 18 16 
19 92 80 98 59 24 99 66 
55 55 16 23 39 80 7 71 
48 95 74 40 42 5 62 76 
28 56 35 43 65 54 59 85 


55 31 3 50 16 84 63 83 
49 10 74 64 79 66 44 49 
34 70 94 7 15 57 18 16 
32 16 36 50 39 95 31 22 
55 55 16 23 39 80 7 71 
19 92 80 98 59 24 99 66 
28 56 35 43 65 54 59 85 
48 95 74 40 42 5 62 76