Advertisement
KRESH-

Untitled

Nov 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <cstdlib>
  2.  
  3. using namespace std;
  4. int main()
  5. {
  6. int n, m;
  7.  
  8. cout << "rows: " << endl;
  9. cin >> n;
  10. cout << "columns: " << endl;
  11. cin >> m;
  12.  
  13. int k = m - 2;
  14. int** arr = new int*[n]; // ARRAY
  15. for (int i = 0; i < n; ++i)
  16. arr[i] = new int[m];
  17.  
  18. for (int i = 0; i < n; i++) // ARRAY INPUT
  19. {
  20. for (int j = 0; j < m; j++)
  21. {
  22. if (i <= n-2 && j <= k)
  23. {
  24. arr[i][j] = 0;
  25. }
  26. else
  27. {
  28. arr[i][j] = rand() % 135 + (-12);
  29. }
  30.  
  31. }
  32. k--;
  33. }
  34.  
  35. for (int i = 0; i < n; i++) // ARRAY OUTPUT
  36. {
  37. for (int j = 0; j < n; j++)
  38. {
  39. cout << arr[i][j] << endl;
  40. }
  41. }
  42.  
  43. delete[] arr; // FREEING MEMORY
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement