Advertisement
Guest User

ddddd

a guest
Dec 7th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.62 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int xstr=3,yst=4;
  6. int zeroStolbec;
  7. int sum=0;
  8. bool isChecked =false;
  9. cout <<"input x y\n";
  10. //cin >>xstr;
  11. //cin >>yst;
  12. int characteristic;
  13. int *mas =new int [xstr]; //mas dlya result parnych neg element
  14. for(int i=0;i<xstr;i++)
  15. {
  16.     mas[i]=0;
  17. }
  18. int **a = new int * [xstr];
  19. for (int i = 0; i<xstr; i++)
  20. {
  21.     a[i] = new int [yst];
  22. }
  23. a[0][0]=-3;
  24. a[0][1]=-1;
  25. a[0][2]=-2;
  26. a[0][3]=-3;
  27.  
  28. a[1][0]=-2;
  29. a[1][1]=-1;
  30. a[1][2]=-0;
  31. a[1][3]=-1;
  32.  
  33. a[2][0]=-20;
  34. a[2][1]=-20;
  35. a[2][2]=-20;
  36. a[2][3]=-20;
  37. /*
  38. for(int i=0;i<xstr;i++)
  39. {
  40.     for(int j=0;j<yst;j++)
  41.     {
  42.         int g;
  43.         cout <<"input"<<i<<" "<<j<<"\n";
  44.         cin>> g;
  45.         a[i][j]=g;
  46.     }
  47. }
  48. */
  49. for(int j=0;j<yst;j++)
  50. {
  51.    
  52.     for(int i=0;i<xstr;i++)
  53.     {
  54.         cout<<j<<"/t"<<i<<endl;
  55.         if(a[i][j]==0 && !isChecked)
  56.         {
  57.             cout<<"found"<<j<<"/t"<<i<<endl;
  58.             zeroStolbec=j;
  59.             isChecked=true;//не дает заново проверять  работает
  60.         }
  61.        
  62.     }
  63. }
  64.  for(int i=0;i<xstr;i++)
  65.     {
  66.     for(int j=0;j<yst;j++)
  67.     {
  68.         cout<<a[i][j]<<"\t";
  69.     }
  70.         cout<<"\n";
  71.     }
  72.  cout<<"--------------------------------------------mas add-----------------------------------------------"<<endl<<endl;
  73. for(int i=0;i<xstr;i++)
  74. {
  75.    
  76.     for(int j=0;j<yst;j++)
  77.     {
  78.         if(a[i][j]%2==0 && a[i][j]<0)
  79.         {
  80.             mas[i]=abs(mas[i]+a[i][j]);
  81.             cout <<mas[i]<<"\n\t";
  82.         }
  83.  
  84.     }
  85. }
  86. cout <<"\n--------------------------------------------------mas sort------------------------------------------------"<<endl;
  87.  
  88.      for (int i = 0; i < xstr; i++)
  89.      {
  90.        bool swapped = false;
  91.            for (int j = 0; j < xstr-i-1; j++) {                 //не до конца сортирует. я хз чего он так. на сортировкой подумать и думаю будет норм.
  92.               if (mas[j] > mas[j+1]) {
  93.                   int temp=mas[j];
  94.                   mas[j]=mas[j+1];
  95.                   mas[j+1]=temp;
  96.                 int * b = a[j];                                 // если что, то ты просто тут указатели на строку меняешь. ps посмотри фотки в гугле динамический двухмерный массив
  97.                  a[j] = a[j+1];
  98.                   a[j+1] = b;
  99.                  swapped = true;
  100.              }
  101.          }          
  102.          if(!swapped)
  103.             break;
  104.      
  105.         }
  106.      cout<<"\n--------------------------------------------------------endsort-------------------------------------------------------"<<endl;
  107.  
  108.      for(int i=0;i<xstr;i++)
  109.     {
  110.     for(int j=0;j<yst;j++)
  111.     {
  112.         cout<<a[i][j]<<"\t";
  113.     }
  114.         cout<<"\n";
  115.     }
  116.      cout << "zero stolbec-"<<zeroStolbec<<endl;
  117.      system("PAUSE");
  118.      return 0;
  119.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement