Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- setlocale (LC_ALL, "rus");
- int n, m;
- cout << "Введите колв-во строк: ";
- cin >> n;
- cout << "Введите колв-во столбцов: ";
- cin >> m;
- int **a = new int *[n];
- for (int i = 0; i < n; i++)
- a[i] = new int[2*m];
- cout << "Введите элементы: ";
- for (int i = 0; i < n; i++)
- for (int j = 0; j < m; j++) cin >> a[i][j];
- int s;
- for (int j = 0; j < m; j++)
- {
- s = 0;
- for (int i = 0; i < n; i++)
- if (a[i][j] < 0) s++;
- if (s == 0) {
- for (int j1 = m; j1 > j; j1--)
- for (int i1 = 0; i1 < n; i1++) a[i1][j1] = a[i1][j1 -1];
- m++;
- for (int i1 = 0; i1 < n; i1++) a[i1][j] = 0;
- };
- }
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++) cout << a[i][j] << ' ';
- cout << endl;
- }
- return 0;
- }
- Введите колв-во строк: 3
- Введите колв-во столбцов: 3
- Введите элементы: 1 2 3 1 2 3 12 2 3
- Segmentation fault (core dumped)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement