Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int m;
- int n;
- int a[100][100];
- int Zero, c;
- int null = 0;
- cout << "enter the number of strings: ";
- cin >> m;
- cout << "enter the number of columns: ";
- cin >> n;
- for (int i = 0; i < m; i++) //заполнение
- {
- for (int j = 0; j < n; j++)
- {
- a[i][j] = rand() % 10;
- cout << a[i][j] << "\t";
- }
- cout << endl;
- }
- cout << "enter the amount of zeros: ";
- cin >> Zero;
- for (int j = 0; j < n; j++)
- {
- for (int i = 0; i < m; i++)
- {
- if (a[i][j] == 0)
- {
- null++; //подсчёт нулей в столбце
- }
- }
- if (null == Zero)
- {
- c = j;
- break;
- }
- null = 0;
- }
- for (int j = c; j < n - 1; j++) //перемещение столбцов
- {
- for (int i = 0; i < m; i++)
- {
- a[i][j] = a[i][j+1];
- }
- cout << endl;
- }
- for (int i = 0; i < m; i++) {
- a[i][n-1] = 0;
- }
- cout << endl;
- for (int i = 0; i < m; i++) //вывод массива 2
- {
- for (int j = 0; j < n; j++)
- {
- cout << a[i][j] << "\t";
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement