DEC-UPDATE

12/19-12/26

 

 

# - * - coding: utf-8 - * - 

import sys 
years = [1,2,3,4,5,6 ] 

def operate (fun): 
    
    a = age [0] 
    b = years [1 ] 
    c = years [2 ] 
    d = years [3 ] 
    e = years [4 ] 
    f = years [5 ] 
    
    if fun == ' R ' : 
       years [0] = d 
       years [ 1] = c 
       years [ 2] = a 
       years [ 3 ] = b
     eliffun == ' L ' : 
        years [0] = c 
        years [ 1] = d 
        years [ 2] = b 
        years [ 3] = a
     elif fun == ' B ' : # #上 
        years [2] = f 
        years [ 3] = e 
        years [ 4] = c 
        years [ 5] = d
     elif fun == ' C ' : # #下 
        years [2] = e 
        years [3] = f 
        years [ 4] = d 
        years [ 5] = c
     elif fun == ' A ' : # #顺90 
        years [0] = e 
        years [ 1] = f 
        years [ 4] = b 
        years [ 5] = has
     elif fun == ' F ' : # #逆90 
        years [0] = f 
        years [ 1] = e 
        years [ 4] = a 
        year [ 5] = b

if __name__ == '__main__':
    
    while(True):
        args = raw_input()
        if args == 'q':
            break
        map(operate, args)
        for e in ans:
            sys.stdout.write(str(e))
        ans = [1,2,3,4,5,6]
        sys.stdout.write('\n')  
Python CODE

 

#include <stdio.h>
#include <stdlib.h>

#define INPUT 60

void L(int *ans);
void R(int *ans);
void F(int *ans);
void B(int *ans);
void A(int *ans);
void C(int *ans);
int  getlen(char *test){
    int c = 0;
    while(*test++ != '\0'){
        c++;
    }

    return c;
}



int main()
{
    int ans[] = {1,2,3,4,5,6};
    char inputs[INPUT] = "";
    int i = 0;

    while(gets(inputs)){

        for (i = 0; i < getlen(inputs); i++){

            if(inputs[i] == 'R'){
                R(ans); 
            }else if(inputs[i] == 'L'){
                L(ans);
            }else if(inputs[i] == 'A'){
                A(ans);
            }else if(inputs[i] == 'B'){
                B(ans);
            }else if(inputs[i] == 'C'){
                C(ans);
            }else if(inputs[i] == 'F'){
                F(ans);
            }
        }
        for (i = 0 ;i < 6; i++){
            printf("%d", ans[i]);
        }
        printf("\n");
        for(i = 0; i < 6; i++){
            ans[i] = i + 1;
        }
    }
    return 0;
}

void R(int *t){
    int a = t[3];
    int b = t[2];
    int c = t[1];
    int d = t[0];

    t[3] = c;
    t[2] = d;
    t[1] = b;
    t[0] = a;
}

void L(int *t){
    int a = t[3];
    int b = t[2];
    int c = t[1];
    int d = t[0];

    t[3] = d;
    t[2] = c;
    t[1] = a;
    t[0] = b;
}


void F(int *t){
    int a = t[5];
    int b = t[4];
    int c = t[3];
    int d = t[2];

    t[5] = c;
    t[4] = d;
    t[3] = b;
    t[2] = a;
}

void B(int *t){
    int a = t[5];
    int b = t[4];
    int c = t[3];
    int d = t[2];

    t[5] = d;
    t[4] = c;
    t[3] = a;
    t[2] = b;
}

void A(int *t){
    int a = t[5];
    int b = t[4];
    int c = t[1];
    int d = t[0];

    t[5] = d;
    t[4] = c;
    t[1] = a;
    t[0] = b;
}

void C(int *t){
    int a = t[5];
    int b = t[4];
    int c = t[1];
    int d = t[0];

    t[5] = c;
    t[4] = d;
    t[1] = b;
    t[0] = a;
}
C CODE

 

Guess you like

Origin www.cnblogs.com/hdu-2010/p/12090948.html