DEC-UPDATE

Posted hdu-2010

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DEC-UPDATE相关的知识,希望对你有一定的参考价值。

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(
)  
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++ != ){
        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("
");
        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的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数