Advertisement
STANAANDREY

st_lin_max

May 13th, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int n,i,j,a[100][100],k,m,nr,v[100],maxi=0,c;
  7. cout<<"n=";cin>>n;
  8. cout<<"m=";cin>>m;
  9. for (i=0;i<n;i++)
  10.     for (j=0;j<m;j++)
  11.      cin>>a[i][j];
  12.  
  13. for (i=0;i<n;i++) {
  14.         nr=0;
  15.     for (j=0;j<m;j++)
  16.     if (!a[i][j])
  17.     nr++;
  18.    if (maxi<nr)
  19.    {
  20.        k=0;
  21.        maxi=nr;
  22.        v[k]=i;
  23.    }
  24. else
  25.     if (nr==maxi&&nr)
  26. {
  27.     k++;
  28.     v[k]=i;
  29. }
  30. }
  31. k++;
  32. for (c=0;c<k;c++)
  33.     {
  34. for (i=v[c];i<n-1;i++)
  35.     for (j=0;j<m;j++)
  36.     a[i][j]=a[i+1][j];
  37. n--;
  38. }
  39. cout<<endl<<"matricea noua:"<<endl;
  40.  
  41. for (i=0;i<n;i++) {
  42.     for (j=0;j<m;j++)
  43. cout<<a[i][j]<<' ';
  44. cout<<endl;
  45. }//*/
  46.   return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement