码迷,mamicode.com
首页 > 其他好文 > 详细

DEC-UPDATE

时间:2019-12-24 13:58:58      阅读:65      评论:0      收藏:0      [点我收藏+]

标签:port   span   NPU   bre   imp   lap   ==   pre   tle   

12/19-12/26

 

 

技术图片
# -*- coding: utf-8 -*-

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

def operate(fun):
    
    a = ans[0]
    b = ans[1]
    c = ans[2]
    d = ans[3]
    e = ans[4]
    f = ans[5]
    
    if fun == R:
       ans[0] = d
       ans[1] = c
       ans[2] = a
       ans[3] = b
    elif fun == L:
        ans[0] = c
        ans[1] = d
        ans[2] = b
        ans[3] = a
    elif fun == B: ##上
        ans[2] = f
        ans[3] = e
        ans[4] = c
        ans[5] = d
    elif fun == C: ##下
        ans[2] = e
        ans[3] = f
        ans[4] = d
        ans[5] = c
    elif fun == A: ##顺90
        ans[0] = e
        ans[1] = f
        ans[4] = b
        ans[5] = a
    elif fun == F: ##逆90
        ans[0] = f
        ans[1] = e
        ans[4] = a
        ans[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

 

DEC-UPDATE

标签:port   span   NPU   bre   imp   lap   ==   pre   tle   

原文地址:https://www.cnblogs.com/hdu-2010/p/12090948.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!