Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <vector>
- #include <math.h>
- using namespace std;
- short TF(short In)
- {
- if(In==0)return 3;
- if(In==1)return 2;
- if(In==2)return 1;
- if(In==3)return 0;
- }
- struct CH;
- vector <CH*> Lista;
- struct CH
- {
- CH* W[4]; int WW[4];
- CH* Here;
- short Wodory;
- void DC(short Wi)
- {
- if(WW[Wi]!=0)return;
- W[Wi]=new CH;
- WW[Wi]=-3;
- Lista.push_back(W[Wi]);
- W[Wi]->WW[0]=0;W[Wi]->W[0]=0;
- W[Wi]->WW[1]=0;W[Wi]->W[1]=0;
- W[Wi]->WW[2]=0;W[Wi]->W[2]=0;
- W[Wi]->WW[3]=0;W[Wi]->W[3]=0;
- if(Wi==0){W[Wi]->W[3]=Here;W[Wi]->WW[3]=-3;}
- if(Wi==1){W[Wi]->W[2]=Here;W[Wi]->WW[2]=-3;}
- if(Wi==2){W[Wi]->W[1]=Here;W[Wi]->WW[1]=-3;}
- if(Wi==3){W[Wi]->W[0]=Here;W[Wi]->WW[0]=-3;}
- W[Wi]->Wodory=3; Wodory--;
- }
- int UDroge(short Wi)
- {
- int Max=0;int N;
- for(N=0;N<4;N++)
- {
- if(Wi!=N)
- {
- if(WW[N]==-3)
- WW[N]=W[N]->UDroge(TF(N))+1;
- if(WW[N]>Max)
- Max=WW[N];
- }
- }
- return Max;
- }
- };
- int main()
- {
- CH Czastka;
- Czastka.Here=&Czastka;
- Czastka.Wodory=4;
- Lista.push_back(&Czastka);
- Czastka.W[0]=0;
- Czastka.W[1]=0;
- Czastka.W[2]=0;
- Czastka.W[3]=0;
- Czastka.WW[0]=0;
- Czastka.WW[1]=0;
- Czastka.WW[2]=0;
- Czastka.WW[3]=0;
- Czastka.DC(0);
- Czastka.W[0]->DC(0);
- Czastka.W[0]->W[0]->DC(1);
- Czastka.W[0]->W[0]->DC(0);
- Czastka.W[0]->W[0]->W[0]->DC(0);
- Czastka.W[0]->W[0]->W[0]->W[0]->DC(0);
- int I=0;
- int A=0;
- int Max=0;
- for(I=Lista.size()-1;I>=0;I--)
- if(Lista[I]->Wodory>=3)
- {
- for(A=0;A<4;A++)if(Lista[I]->WW[A]!=0)
- {
- Lista[I]->WW[A]=Lista[I]->UDroge(int(sqrt((A-1)*(A-1))));
- if(Max<Lista[I]->WW[A])Max=Lista[I]->WW[A];
- }
- }
- cout<<Max;
- int Wegle;
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement