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 summ, c;
- int sum = 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";
- sum += a[i][j];
- }
- cout << "sum of the string: " << sum;
- cout << endl;
- sum = 0;
- }
- cout << "enter the sum for comparison: ";
- cin >> summ;
- for (int i = 0; i < m; i++) //сравнение с заданным числом
- {
- for (int j = 0; j < n; j++)
- {
- sum += a[i][j];
- }
- if (sum < summ)
- {
- c = i;
- break;
- }
- sum = 0;
- }
- for (int i = c; i < m - 1; i++) //перемещение строк
- {
- for (int j = 0; j < n; j++)
- {
- a[i][j] = a[i + 1][j];
- }
- cout << endl;
- }
- for (int j = 0; j < n; j++) { //обнуление последней строки
- a[m - 1][j] = 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