Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int m, n, **arr, first_raw_average = 0;
- cout << "Number of rows n = ";
- cin >> n;
- cout << "Number of columns in each row m = ";
- cin >> m;
- cout << "Enter values for the next elements: " << endl;
- arr = new int*[n];
- for (int row = 0; row < n; ++row)
- {
- arr[row] = new int[m];
- for (int column = 0; column < m; ++column)
- {
- cout << "Element " << column + 1 << " from row " << row + 1 << " = ";
- cin >> arr[row][column];
- if (row == 0)
- first_raw_average += arr[row][column];
- }
- }
- first_raw_average /= m;
- cout << endl << "Columns without zero:";
- for (int row, column = 0; column < m; ++column)
- {
- for (row = 0; row < n; ++row)
- if (arr[row][column] == 0)
- break ;
- if (row == n)
- cout << " " << column;
- }
- cout << endl << endl;
- cout << "Original array:" << endl;
- for (int column, row = 0; row < n; ++row)
- {
- cout << "\t";
- for (column = 0; column < m; ++column)
- {
- cout << arr[row][column];
- if (column + 1 < m)
- cout << " ";
- }
- cout << endl;
- }
- cout << endl;
- cout << "Modified array:" << endl;
- for (int column, row = 0; row < n; ++row)
- {
- cout << "\t";
- for (column = 0; column < m; ++column)
- {
- if (row == 0)
- arr[row][column] += first_raw_average;
- cout << arr[row][column];
- if (column + 1 < m)
- cout << " ";
- }
- cout << endl;
- }
- cout << endl;
- for (int i = 0; i < n; ++i)
- delete[] arr[i];
- delete[] arr;
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement