Home
О нас
Products
Services
Регистрация
Войти
Поиск
Link96
@Link96
July 2022
1
10
Report
Дан двумерный массив, добавить строку из цифр "5" после строк, в которых есть нулевые элементы. Написать код в C++
Please enter comments
Please enter your name.
Please enter the correct email address.
Agree to
terms of service
You must agree before submitting.
Send
Answers & Comments
Gleb1Kosyrev
Verified answer
//Dev-C++ 4.9.9.2
#include <iostream>
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<n*2;i++)
for(int j=0;j<n;j++)
ma[i][j]=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cin>>ma[i][j];
cout<<"Matrix:"<<endl;
for(int i=0;i<nr;i++){
for(int j=0;j<n;j++)
cout<<ma[i][j]<<' ';
cout<<endl;}
for(int i=0;i<nr;i++){
for(int j=0;j<n;j++){
if(ma[i][j]==0)b=true;}
if(b==true){
for(int z=nr-1;z>i;z--){
for(int c=0;c<n;c++)
ma[z+1][c]=ma[z][c];}
for(int c=0;c<n;c++)
ma[i+1][c]=5;
nr++;}
b=false;}
cout<<"Final matrix:"<<endl;
for(int i=0;i<nr;i++){
for(int j=0;j<n;j++)
cout<<ma[i][j]<<' ';
cout<<endl;
}
cin.get();
cin.get();
return 0;
}
0 votes
Thanks 0
More Questions From This User
See All
Link96
July 2022 | 0 Ответы
Уравнение (x^2+x+4 под корнем) +(x^2+x+1 под корнем) = (2x^2+2x+9 под корнем) ре...
Answer
Link96
July 2022 | 0 Ответы
tex]...
Answer
Link96
July 2022 | 0 Ответы
Написать программу. Чтоб вводимое число делилось на 2 пока она не станет 0. И пу...
Answer
Link96
July 2022 | 0 Ответы
tex](2x-5)=-2...
Answer
Link96
September 2021 | 0 Ответы
...
Answer
рекомендуемые вопросы
rarrrrrrrr
August 2022 | 0 Ответы
о чем должны позаботиться в первую очередь взрослые при организационном вывозе н...
danilarsentev
August 2022 | 0 Ответы
Есть два станка на которых выпускают одинаковые запчасти один производит a запча...
myachina8
August 2022 | 0 Ответы
Найти по графику отношение V3:V1. В ответах написано 9, но нужно решение...
ydpmn7cn6w
August 2022 | 0 Ответы
Choose the correct preposition: 1.I am fond (out,of,from) literature. 2.where ar...
millermilena658
August 2022 | 0 Ответы
Определите Как создавалась и кто создавал арабское государство в крации...
MrZooM222
August 2022 | 0 Ответы
Ч. Айтманов в рассказе "Красное яблоко" использует метод рассказ в рассказе. Опи...
timobila47
August 2022 | 0 Ответы
каково было назначение каждой из частей византийского храма? помогите пожалуйста...
ivanyyaremkiv
August 2022 | 0 Ответы
moment. 6....
Участник Знаний
August 2022 | 0 Ответы
Пожалуйста!!!!!!!!!!!!...
sarvinozwakirjanova
August 2022 | 0 Ответы
помогите пожалусто пж...
×
Report "Дан двумерный массив, добавить строку из цифр "5" после строк, в которых есть ну..."
Your name
Email
Reason
-Select Reason-
Pornographic
Defamatory
Illegal/Unlawful
Spam
Other Terms Of Service Violation
File a copyright complaint
Description
Helpful Links
О нас
Политика конфиденциальности
Правила и условия
Copyright
Контакты
Helpful Social
Get monthly updates
Submit
Copyright © 2025 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
//Dev-C++ 4.9.9.2#include <iostream>
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<n*2;i++)
for(int j=0;j<n;j++)
ma[i][j]=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cin>>ma[i][j];
cout<<"Matrix:"<<endl;
for(int i=0;i<nr;i++){
for(int j=0;j<n;j++)
cout<<ma[i][j]<<' ';
cout<<endl;}
for(int i=0;i<nr;i++){
for(int j=0;j<n;j++){
if(ma[i][j]==0)b=true;}
if(b==true){
for(int z=nr-1;z>i;z--){
for(int c=0;c<n;c++)
ma[z+1][c]=ma[z][c];}
for(int c=0;c<n;c++)
ma[i+1][c]=5;
nr++;}
b=false;}
cout<<"Final matrix:"<<endl;
for(int i=0;i<nr;i++){
for(int j=0;j<n;j++)
cout<<ma[i][j]<<' ';
cout<<endl;
}
cin.get();
cin.get();
return 0;
}