Advertisement
juanjo12x

UVA_12503_Robot_Instruction

Jun 13th, 2014
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. int main(int argc, char** argv) {
  5.     int t,n,i,cont,index;
  6.     scanf("%d",&t);
  7.     while(t--){
  8.         cont=0;/*origin*/
  9.         scanf("%d",&n);
  10.         int coord[n];
  11.         char buff[15];
  12.         for(i=0;i<n;i++){
  13.            
  14.             scanf("%s",&buff);
  15.             if (strcmp(buff,"LEFT")==0){
  16.                 cont--;
  17.                 coord[i]=-1;
  18.             }
  19.             if(strcmp(buff,"RIGHT")==0){
  20.                 cont++;
  21.                 coord[i]=1;
  22.             }
  23.             if (strcmp(buff,"SAME")==0){
  24.                 scanf("%s %d",&buff,&index);
  25.                 cont+=coord[index-1];
  26.                 coord[i]=coord[index-1];
  27.             }
  28.         }
  29.         printf("%d\n",cont);
  30.     }
  31.     return (EXIT_SUCCESS);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement