Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int f(int a, int b){
  4. return a+b;
  5. }
  6. int main() {
  7. int c=1,d=2,x,PONTO_ATUAL,y,PONTO_OBJETIVO;
  8. scanf("%d",&PONTO_OBJETIVO);
  9. while (PONTO_ATUAL<PONTO_OBJETIVO){
  10. if (PONTO_ATUAL<PONTO_OBJETIVO){
  11. y=y+(1*c);
  12. PONTO_ATUAL=PONTO_ATUAL+(1*c);
  13. if (PONTO_ATUAL>PONTO_OBJETIVO){
  14. y=y-(PONTO_ATUAL-PONTO_OBJETIVO);
  15. }
  16. }
  17. if (PONTO_ATUAL==PONTO_OBJETIVO){break;}
  18. if (PONTO_ATUAL<PONTO_OBJETIVO){
  19. x=x-(1*c);
  20. PONTO_ATUAL=PONTO_ATUAL+(1*c);
  21. if (PONTO_ATUAL>PONTO_OBJETIVO){
  22. x=x+(PONTO_ATUAL-PONTO_OBJETIVO);
  23. }
  24. }
  25. if (PONTO_ATUAL==PONTO_OBJETIVO){break;}
  26. if (PONTO_ATUAL<PONTO_OBJETIVO){
  27. y=y-(1*d);
  28. PONTO_ATUAL=PONTO_ATUAL+(1*d);
  29. if (PONTO_ATUAL>PONTO_OBJETIVO){
  30. y=y+(PONTO_ATUAL-PONTO_OBJETIVO);
  31. }
  32. }
  33. if (PONTO_ATUAL==PONTO_OBJETIVO){break;}
  34. if (PONTO_ATUAL<PONTO_OBJETIVO){
  35. x=x+(1*d);
  36. PONTO_ATUAL=PONTO_ATUAL+(1*d);
  37. if (PONTO_ATUAL>PONTO_OBJETIVO){
  38. x=x-(PONTO_ATUAL-PONTO_OBJETIVO);
  39. }
  40. }
  41. if (PONTO_ATUAL==PONTO_OBJETIVO){break;}
  42. c=c+2;
  43. d=d+2;
  44. }
  45. printf ("%d %d\n",x,y);
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement