Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. setlocale (LC_ALL, "rus");
  7. int n, m;
  8. cout << "Введите колв-во строк: ";
  9. cin >> n;
  10. cout << "Введите колв-во столбцов: ";
  11. cin >> m;
  12. int **a = new int *[n];
  13. for (int i = 0; i < n; i++)
  14. a[i] = new int[2*m];
  15. cout << "Введите элементы: ";
  16. for (int i = 0; i < n; i++)
  17. for (int j = 0; j < m; j++) cin >> a[i][j];
  18.  
  19. int s;
  20. for (int j = 0; j < m; j++)
  21. {
  22. s = 0;
  23. for (int i = 0; i < n; i++)
  24. if (a[i][j] < 0) s++;
  25. if (s == 0) {
  26. for (int j1 = m; j1 > j; j1--)
  27. for (int i1 = 0; i1 < n; i1++) a[i1][j1] = a[i1][j1 -1];
  28. m++;
  29. for (int i1 = 0; i1 < n; i1++) a[i1][j] = 0;
  30. };
  31. }
  32.  
  33. for (int i = 0; i < n; i++)
  34. {
  35. for (int j = 0; j < m; j++) cout << a[i][j] << ' ';
  36. cout << endl;
  37. }
  38. return 0;
  39. }
  40.  
  41. Введите колв-во строк: 3
  42. Введите колв-во столбцов: 3
  43. Введите элементы: 1 2 3 1 2 3 12    2  3
  44. Segmentation fault (core dumped)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement