Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- main(){
- int cnt;
- int u_be4;
- int time; /*翻轉骰子的次數*/
- char input[6]; /*翻轉骰子的方向*/
- int u,d,n,s,e,w; /*紀錄骰子六個面上的數字*/
- while(scanf("%d",&time)==1){
- if(time==0)
- break;
- u=1;d=6;n=2;s=5;e=4;w=3;
- for(cnt=0;cnt<time;cnt++){
- scanf("%s",input);
- switch(input[0]){
- case 'n':
- u_be4=u;u=s;s=d;d=n;n=u_be4;
- break;
- case 'e':
- u_be4=u;u=w;w=d;d=e;e=u_be4;
- break;
- case 's':
- u_be4=u;u=n;n=d;d=s;s=u_be4;
- break;
- case 'w':
- u_be4=u;u=e;e=d;d=w;w=u_be4;
- break;
- } /* switch end */
- } /* for end */
- printf("%d\n",u);
- } /* while end */
- system("PAUSE");
- return 0;
- } /* main end */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement