Дан двумерный массив, добавить строку из цифр "5" после строк, в которых есть нулевые...

0 голосов
19 просмотров

Дан двумерный массив, добавить строку из цифр "5" после строк, в которых есть нулевые элементы. Написать код в C++


Информатика (159 баллов) | 19 просмотров
Дан 1 ответ
0 голосов
Правильный ответ

//Dev-C++ 4.9.9.2

#include
using namespace std;

const
 int n=3;

int main(){
    int ma[n*2][n];
    bool b;
    int nr=0;
    nr=n;
    b=false;
    for(int i=0;i     for(int j=0;j      ma[i][j]=0;
    for(int i=0;i     for(int j=0;j      cin>>ma[i][j];
    cout<<"Matrix:"<<endl;<br>    for(int i=0;i     for(int j=0;j      cout<<ma[i][j]<<' ';<br>     cout<<endl;}<br>    for(int i=0;i     for(int j=0;j      if(ma[i][j]==0)b=true;}
     if(b==true){
                for(int z=nr-1;z>i;z--){
                 for(int c=0;c                  ma[z+1][c]=ma[z][c];}
                 for(int c=0;c                  ma[i+1][c]=5;
                 nr++;}
     b=false;}
     cout<<"Final matrix:"<<endl;<br>     for(int i=0;i       for(int j=0;j        cout<<ma[i][j]<<' ';<br>      cout<<endl;<br>      }
     cin.get();
     cin.get();
  return 0;
}

(38.6k баллов)