Advertisement
Go-Ice

UVa [10409 - Die Game] by Go-Ice

Sep 27th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. main(){
  5.     int cnt;
  6.     int u_be4;
  7.     int time;       /*翻轉骰子的次數*/
  8.     char input[6];      /*翻轉骰子的方向*/
  9.     int u,d,n,s,e,w;    /*紀錄骰子六個面上的數字*/
  10.    
  11.     while(scanf("%d",&time)==1){
  12.         if(time==0)
  13.             break;
  14.            
  15.         u=1;d=6;n=2;s=5;e=4;w=3;
  16.         for(cnt=0;cnt<time;cnt++){
  17.             scanf("%s",input);
  18.             switch(input[0]){
  19.                 case 'n':
  20.                     u_be4=u;u=s;s=d;d=n;n=u_be4;
  21.                     break;
  22.                 case 'e':
  23.                     u_be4=u;u=w;w=d;d=e;e=u_be4;
  24.                     break;
  25.                 case 's':
  26.                     u_be4=u;u=n;n=d;d=s;s=u_be4;
  27.                     break;
  28.                 case 'w':
  29.                     u_be4=u;u=e;e=d;d=w;w=u_be4;
  30.                     break;
  31.             } /* switch end */
  32.         } /* for end */
  33.         printf("%d\n",u);
  34.     } /* while end */
  35.    
  36.     system("PAUSE");
  37.     return 0;
  38. } /* main end */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement