Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int xstr=3,yst=4;
- int zeroStolbec;
- int sum=0;
- bool isChecked =false;
- cout <<"input x y\n";
- //cin >>xstr;
- //cin >>yst;
- int characteristic;
- int *mas =new int [xstr]; //mas dlya result parnych neg element
- for(int i=0;i<xstr;i++)
- {
- mas[i]=0;
- }
- int **a = new int * [xstr];
- for (int i = 0; i<xstr; i++)
- {
- a[i] = new int [yst];
- }
- a[0][0]=-3;
- a[0][1]=-1;
- a[0][2]=-2;
- a[0][3]=-3;
- a[1][0]=-2;
- a[1][1]=-1;
- a[1][2]=-0;
- a[1][3]=-1;
- a[2][0]=-20;
- a[2][1]=-20;
- a[2][2]=-20;
- a[2][3]=-20;
- /*
- for(int i=0;i<xstr;i++)
- {
- for(int j=0;j<yst;j++)
- {
- int g;
- cout <<"input"<<i<<" "<<j<<"\n";
- cin>> g;
- a[i][j]=g;
- }
- }
- */
- for(int j=0;j<yst;j++)
- {
- for(int i=0;i<xstr;i++)
- {
- cout<<j<<"/t"<<i<<endl;
- if(a[i][j]==0 && !isChecked)
- {
- cout<<"found"<<j<<"/t"<<i<<endl;
- zeroStolbec=j;
- isChecked=true;//не дает заново проверять работает
- }
- }
- }
- for(int i=0;i<xstr;i++)
- {
- for(int j=0;j<yst;j++)
- {
- cout<<a[i][j]<<"\t";
- }
- cout<<"\n";
- }
- cout<<"--------------------------------------------mas add-----------------------------------------------"<<endl<<endl;
- for(int i=0;i<xstr;i++)
- {
- for(int j=0;j<yst;j++)
- {
- if(a[i][j]%2==0 && a[i][j]<0)
- {
- mas[i]=abs(mas[i]+a[i][j]);
- cout <<mas[i]<<"\n\t";
- }
- }
- }
- cout <<"\n--------------------------------------------------mas sort------------------------------------------------"<<endl;
- for (int i = 0; i < xstr; i++)
- {
- bool swapped = false;
- for (int j = 0; j < xstr-i-1; j++) { //не до конца сортирует. я хз чего он так. на сортировкой подумать и думаю будет норм.
- if (mas[j] > mas[j+1]) {
- int temp=mas[j];
- mas[j]=mas[j+1];
- mas[j+1]=temp;
- int * b = a[j]; // если что, то ты просто тут указатели на строку меняешь. ps посмотри фотки в гугле динамический двухмерный массив
- a[j] = a[j+1];
- a[j+1] = b;
- swapped = true;
- }
- }
- if(!swapped)
- break;
- }
- cout<<"\n--------------------------------------------------------endsort-------------------------------------------------------"<<endl;
- for(int i=0;i<xstr;i++)
- {
- for(int j=0;j<yst;j++)
- {
- cout<<a[i][j]<<"\t";
- }
- cout<<"\n";
- }
- cout << "zero stolbec-"<<zeroStolbec<<endl;
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement