View Code of Problem 135

#include <stdio.h>
#include<string.h>
void main(){
  int m;
  char str[100];
  int walk,move1,move2;
  while(scanf("%d",&m)!=EOF){
  	walk=0;move1=0;move2=0;
    	gets(str);
   	for(i=0;i<m;i++){
    	  for(int j=1;j<strlen(str);j++){
    		walk = walk*10 + (str[j]-'0');
          }
    	  if(str[0]=='L')move1-=walk;
    	  if(str[0]=='R')move1+=walk;
    	  if(str[0]=='F')move2+=walk;
    	  if(str[0]=='B')move2-=walk;
       }
       int x,y;
       scanf("%d %d",&x,&y);
       if(move1==x&&move2==y)
   	 printf("MEME IS SO LUCKY\n");
       else
    	 printf("GPS ERROR\n");
  }
}
/*
Main.c:3:6: warning: return type of 'main' is not 'int' [-Wmain]
 void main(){
      ^
Main.c: In function 'main':
Main.c:9:6: warning: 'gets' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
      gets(str);
      ^
Main.c:10:9: error: 'i' undeclared (first use in this function)
     for(i=0;i<m;i++){
         ^
Main.c:10:9: note: each undeclared identifier is reported only once for each function it appears in
*/

Double click to view unformatted code.


Back to problem 135