Advertisement
labyyysosaaat

Untitled

Sep 30th, 2019
160
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. using namespace std;
  3.  
  4. int main() {
  5. setlocale(LC_ALL, "Russian");
  6. int rows = 0;
  7. int cols = 0;
  8. cout << "Введите количество строк: ";
  9. cin >> rows;
  10. cout << "Введите количество столбцов: ";
  11. cin >> cols;
  12. if (int(rows) <= 0 || int(rows) > 20 || int(cols) <= 0 || int(cols) > 20)
  13. {
  14. cout << "Введены неверные значение" << endl;
  15. system("pause");
  16. return 0;
  17. }
  18.  
  19. int **arr = new int*[rows];
  20. for (int i = 0; i < rows; i++) {
  21. arr[i] = new int[cols];
  22. }
  23. for (int i = 0; i < rows; i++) {
  24.  
  25. for (int j = 0; j < cols; j++) {
  26. cout << "строка # " << i + 1 << "\t";
  27. cout << "столбец # " << j + 1 << "= ";
  28. cin >> arr[i][j];
  29.  
  30. }
  31. }
  32. for (int i = 0; i < rows; i++) {
  33. for (int j = 0; j < cols; j++) {
  34. cout << arr[i][j] << "\t";
  35.  
  36. }
  37. cout << endl;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement