Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- const int n = 2;
- const int m = 3;
- int** a = new int*[n];
- int nStrings = 0;
- for (int i = 0; i < n; i++) {
- bool noZeros = true;
- a[i] = new int[m];
- for (int j = 0; j < m; j++) {
- cin >> a[i][j];
- if (a[i][j] == 0) {
- noZeros = false;
- }
- }
- if (noZeros == true) {
- nStrings++;
- for (int j = 0; j < m; j++) {
- a[i][j] = 3;
- }
- }
- }
- cout << "Исходный массив: \n";
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- cout << a[i][j] << " ";
- }
- cout << "\n";
- }
- cout << "Преобразованный массив: \n";
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- cout << a[i][j] << " ";
- }
- cout << "\n";
- }
- cout << "Количество строк без нулей: " << nStrings;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement