Untitled

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> int main(void) { int x1, x2, y1, y2, l1, l2, p, x, y,i; scanf("%d%d", &x, &y); scanf("%d", &p); i=1; x1=1; y1=1; x2=x; y2=y; while(i<=p) { scanf("%d%d", &l1, &l2); if(l1==1) y1++; if(l1==2) y1--; if(l1==3) x1++; if(l1==4) x1--; if(l2==1) y2++; if(l2==2) y2--; if(l2==3) x2++; if(l2==4) x2--; if((x1==x2 && y1==y2) || x1<1 || x1>x || x2<1 || x2>x || y1<1 || y2<1 || y2>y) break; i++; } if((x1<1 || x1>x || y1<1 || y1>y) && (x2<1 || x2>x || y2<1 || y2>y)) printf("PA saiu na posicao (%d,%d) no passo %d\n", x1,y1,i--); else if(x1==x2 && y1==y2) printf("Encontraram-se na posicao (%d,%d) no passo %d\n", x1, y1, i--); else if(x1<1 || x1>x || y1<1 || y1>y) printf("PA saiu na posicao (%d,%d) no passo %d\n", x1,y1,i--); else if(x2<1 || x2>x || y2<1 || y2>y) printf("PB saiu na posicao (%d,%d) no passo %d\n", x2,y2,i--); else printf("Nao se encontraram\n"); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines