Advertisement
juanjo12x

UVA_10409_Die_Game

Jul 31st, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cstring>
  5. #include <string>
  6. #include <cctype>
  7. #include <stack>
  8. #include <queue>
  9. #include <list>
  10. #include <vector>
  11. #include <map>
  12. #include <set>
  13. #include <sstream>
  14. #include <stdlib.h>
  15. #include <cmath>
  16. #define LL unsigned long long
  17. using namespace std;
  18.  
  19. int main() {
  20.         int c,t,n,w,s,e,b,tmp1,tmp;
  21.         while (scanf("%d",&c)){
  22.                 if(c==0) break;
  23.                  t=1; n=2; w=3; s=5; e=4; b=6;
  24.                 while(c--){
  25.                 char buffer[1024];
  26.                 cin>>buffer;
  27.                 if(buffer[0]=='n'){
  28.                     tmp=s;tmp1=n;n=t;s=b;t=tmp;b=tmp1;  
  29.                 }else if(buffer[0]=='s'){
  30.                     tmp=t;tmp1=s;t=n;s=tmp;n=b;b=tmp1;
  31.                 }else if(buffer[0]=='e'){
  32.                     tmp=t;tmp1=e;t=w;e=tmp;w=b;b=tmp1;
  33.                 }else if (buffer[0]=='w'){
  34.                     tmp=t;tmp1=w;t=e;w=tmp;e=b;b=tmp1;
  35.                 }
  36.                
  37.                
  38.               }
  39.                 printf("%d\n",t);
  40.         }
  41.        
  42.  
  43.         return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement