Zennoma

slonus

Feb 29th, 2020
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include<time.h>
  3. using namespace std;
  4. int main()
  5. {
  6. srand(time(NULL));
  7. int n, m;
  8. puts("inputed row number");
  9. cin >> n;
  10. int** array = new int* [n]; // Создаем массив указателей
  11. puts("input collums number");
  12. cin >> m;
  13. puts("generated matrix");
  14.  
  15. for (int i = 0; i < n; i++)
  16. {
  17. array[i] = new int[m]; // Создаем элементы
  18. }
  19. for (int i = 0; i < n; i++)
  20. {
  21. for (int j = 0; j < m; j++)
  22. {
  23. cout.width(10);
  24. *(*(array + i) + j) = rand() % 21 - 10;
  25. cout << *(*(array + i) + j);
  26. }
  27. cout << endl;
  28. }
  29. cout << "shifted matrix" << endl;
  30. for (int i = 0; i < n; i++)
  31. {
  32. int chet = n - i;
  33. for (int flag = 1; flag < chet; flag++) {
  34. cout.width(10);
  35. cout << "";
  36. }
  37. for (int j = 0; j < m; j++)
  38. {
  39.  
  40. cout.width(10);
  41. cout << *(*(array + i) + j);
  42. }
  43. cout << endl;
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment