Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- inline int next_int()
- {int n=0;
- char c=getchar();
- while(!(c>='0'&&c<='9'))
- c=getchar();
- while(c>='0'&&c<='9')
- {n=n*10+c-'0';
- c=getchar();}
- return n;
- }
- int main()
- {int T,I,J,K,N;
- char* string[40];
- char* final[40];
- for(I=0;I<40;I++)
- final[I]="";
- T=next_int();
- for(I=1;I<=T;I++)
- {N=next_int();
- for(J=0;J<N;J++)
- {gets(string[J]);
- strcpy(final[N-1-J],string[J]);
- }
- strncpy(final[0],"Begin",5);//for the first one
- for(J=N-1,K=1;J>=1,K<N;J--,K++)
- {char *p=string[J];
- char *q=final[K];
- if(*p=='R')
- strncpy(q,"Left",4);
- else if(*p=='L')
- strncpy(q,"Right",5);
- }
- for(J=0;J<N;J++)
- {printf("%s\n",final[J]);}
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement