Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int a[100][100],n,i,j,nr,c,k,m;
- cout<<"n=";cin>>n;
- cout<<"m=";cin>>m;
- for (i=0;i<n;i++)
- for (j=0;j<m;j++)
- cin>>a[i][j];
- cout<<"k=";cin>>k;
- for (i=0;i<m;i++)
- {
- nr=0;
- for (j=0;j<n;j++)
- if (!a[j][i])
- nr++;
- if (nr==k)
- {
- for (j=0;j<n;j++)
- a[j][m]=a[j][i];
- m++;
- for (c=0;c<n;c++)
- for (j=i;j<m-1;j++)
- a[c][j]=a[c][j+1];
- m--;
- }
- }
- cout<<endl;
- for (i=0;i<n;i++) {
- for (j=0;j<m;j++)
- cout<<a[i][j]<<' ';
- cout<<endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment