Skip to content

Commit

Permalink
Merge pull request #124 from bhartimeena/master
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
Abhinandan323 authored Oct 29, 2022
2 parents e052d27 + 4852ab4 commit 36df789
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions C++/SetMatrixZero.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include<bits/stdc++.h>
using namespace std;

int main(){
int n,m;
cin>>n>>m;
int arr[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>arr[i][j];
}
}

for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++){
if(arr[i][j]==0){
arr[i][j]=-1;
}

}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++){
if(arr[i][j]==-1){
arr[i][j]=0;
}

}
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cout<<arr[i][j]<<" ";
}
cout<<endl;
}
return(0);

}

0 comments on commit 36df789

Please sign in to comment.