Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- double szukana=361527;
- // cin>>szukana;
- double a=1,x=0,y=0,i=0/*ile sie wykonalo*/,ilerazy=2 /*ile musi sie wykonac*/;
- double wprawo=1, wgore=1, wlewo=2, wdol=2;
- while(a<szukana)
- {
- while(i!=ilerazy)
- {
- int j=0, k=0, l=0, p=0;
- while(j!=wprawo)
- {
- a=a+1;
- x=x+1;
- j=j+1;
- // cout<<"w prawo: a: "<<a<<" x;y "<<x<<";"<<y<<endl;
- if(a==szukana)
- {
- cout<<x<<";"<<y<<endl;
- cout<<"odl: "<<abs(x)+abs(y)<<endl;
- }
- }
- while(k!=wgore)
- {
- a=a+1;
- y=y+1;
- k=k+1;
- // cout<<"w gore: a: "<<a<<" x;y "<<x<<";"<<y<<endl;
- if(a==szukana)
- {
- cout<<x<<";"<<y<<endl;
- cout<<"odl: "<<abs(x)+abs(y)<<endl;
- }
- }
- while(l!=wlewo)
- {
- a=a+1;
- x=x-1;
- l=l+1;
- // cout<<"w lewo: a: "<<a<<" x;y "<<x<<";"<<y<<endl;
- if(a==szukana)
- {
- cout<<x<<";"<<y<<endl;
- cout<<"odl: "<<abs(x)+abs(y)<<endl;
- }
- }
- while(p!=wdol)
- {
- a=a+1;
- y=y-1;
- p=p+1;
- // cout<<"w dol: a: "<<a<<" x;y "<<x<<";"<<y<<endl;
- if(a==szukana)
- {
- cout<<x<<";"<<y<<endl;
- cout<<"odl: "<<abs(x)+abs(y)<<endl;
- }
- }
- wprawo+=2;
- wgore+=2;
- wlewo+=2;
- wdol+=2;
- i+=1;
- }
- ilerazy+=2;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement