Sicily 1128. DICE

来源:互联网 发布:淘宝店叶琳儿彩妆真假 编辑:程序博客网 时间:2024/05/11 12:56

模拟,将骰子反转后判断即可

#include <iostream>#include <string>using namespace std;int main(){string str;while(cin >> str){if(str[4]=='1'||str[5]=='1'){char ch=str[4];str[4]=str[3];str[3]=str[5];str[5]=str[2];str[2]=ch;}//如果1在上面或者下面就把它反转到一旁 while(str[0]!='1'){char ch=str[0];str[0]=str[3];str[3]=str[1];str[1]=str[2];str[2]=ch;}//将1固定到东的位置 while(str[2]!='2'){char ch=str[4];str[4]=str[3];str[3]=str[5];str[5]=str[2];str[2]=ch;}//将2固定到北的位置 if(str[4]=='3') cout << "right" << endl;else cout << "left" << endl;}}

0 0
原创粉丝点击