Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. double szukana=361527;
  9. // cin>>szukana;
  10.  
  11. double a=1,x=0,y=0,i=0/*ile sie wykonalo*/,ilerazy=2 /*ile musi sie wykonac*/;
  12. double wprawo=1, wgore=1, wlewo=2, wdol=2;
  13.  
  14. while(a<szukana)
  15. {
  16. while(i!=ilerazy)
  17. {
  18. int j=0, k=0, l=0, p=0;
  19.  
  20. while(j!=wprawo)
  21. {
  22. a=a+1;
  23. x=x+1;
  24. j=j+1;
  25. // cout<<"w prawo: a: "<<a<<" x;y "<<x<<";"<<y<<endl;
  26. if(a==szukana)
  27. {
  28. cout<<x<<";"<<y<<endl;
  29. cout<<"odl: "<<abs(x)+abs(y)<<endl;
  30. }
  31. }
  32. while(k!=wgore)
  33. {
  34. a=a+1;
  35. y=y+1;
  36. k=k+1;
  37. // cout<<"w gore: a: "<<a<<" x;y "<<x<<";"<<y<<endl;
  38. if(a==szukana)
  39. {
  40. cout<<x<<";"<<y<<endl;
  41. cout<<"odl: "<<abs(x)+abs(y)<<endl;
  42. }
  43. }
  44. while(l!=wlewo)
  45. {
  46. a=a+1;
  47. x=x-1;
  48. l=l+1;
  49. // cout<<"w lewo: a: "<<a<<" x;y "<<x<<";"<<y<<endl;
  50. if(a==szukana)
  51. {
  52. cout<<x<<";"<<y<<endl;
  53. cout<<"odl: "<<abs(x)+abs(y)<<endl;
  54. }
  55. }
  56. while(p!=wdol)
  57. {
  58. a=a+1;
  59. y=y-1;
  60. p=p+1;
  61. // cout<<"w dol: a: "<<a<<" x;y "<<x<<";"<<y<<endl;
  62. if(a==szukana)
  63. {
  64. cout<<x<<";"<<y<<endl;
  65. cout<<"odl: "<<abs(x)+abs(y)<<endl;
  66. }
  67. }
  68. wprawo+=2;
  69. wgore+=2;
  70. wlewo+=2;
  71. wdol+=2;
  72. i+=1;
  73. }
  74.  
  75. ilerazy+=2;
  76.  
  77. }
  78.  
  79.  
  80.  
  81. return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement