Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int f(int a, int b){
- return a+b;
- }
- int main() {
- int c=1,d=2,x,PONTO_ATUAL,y,PONTO_OBJETIVO;
- scanf("%d",&PONTO_OBJETIVO);
- while (PONTO_ATUAL<PONTO_OBJETIVO){
- if (PONTO_ATUAL<PONTO_OBJETIVO){
- y=y+(1*c);
- PONTO_ATUAL=PONTO_ATUAL+(1*c);
- if (PONTO_ATUAL>PONTO_OBJETIVO){
- y=y-(PONTO_ATUAL-PONTO_OBJETIVO);
- }
- }
- if (PONTO_ATUAL==PONTO_OBJETIVO){break;}
- if (PONTO_ATUAL<PONTO_OBJETIVO){
- x=x-(1*c);
- PONTO_ATUAL=PONTO_ATUAL+(1*c);
- if (PONTO_ATUAL>PONTO_OBJETIVO){
- x=x+(PONTO_ATUAL-PONTO_OBJETIVO);
- }
- }
- if (PONTO_ATUAL==PONTO_OBJETIVO){break;}
- if (PONTO_ATUAL<PONTO_OBJETIVO){
- y=y-(1*d);
- PONTO_ATUAL=PONTO_ATUAL+(1*d);
- if (PONTO_ATUAL>PONTO_OBJETIVO){
- y=y+(PONTO_ATUAL-PONTO_OBJETIVO);
- }
- }
- if (PONTO_ATUAL==PONTO_OBJETIVO){break;}
- if (PONTO_ATUAL<PONTO_OBJETIVO){
- x=x+(1*d);
- PONTO_ATUAL=PONTO_ATUAL+(1*d);
- if (PONTO_ATUAL>PONTO_OBJETIVO){
- x=x-(PONTO_ATUAL-PONTO_OBJETIVO);
- }
- }
- if (PONTO_ATUAL==PONTO_OBJETIVO){break;}
- c=c+2;
- d=d+2;
- }
- printf ("%d %d\n",x,y);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement