1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
| #include<bits/stdc++.h> using namespace std;
const int maxn = 2; char font[maxn][maxn] = {{'R', 'R'}, {'R', 'R'}}; char leftt[maxn][maxn] = {{'B', 'B'}, {'B', 'B'}}; char rightt[maxn][maxn] = {{'G', 'G'}, {'G', 'G'}}; char top[maxn][maxn] = {{'Y', 'Y'}, {'Y', 'Y'}}; char down[maxn][maxn] = {{'W', 'W'}, {'W', 'W'}}; char back[maxn][maxn] = {{'O', 'O'}, {'O', 'O'}}; char op[1000];
void printans() { printf(" "); printf("%c %c\n",top[0][0],top[0][1]); printf(" "); printf("%c %c\n",top[1][0],top[1][1]); printf("%c %c %c %c %c %c %c %c\n",leftt[0][0],leftt[0][1],font[0][0],font[0][1],rightt[0][0],rightt[0][1],back[0][0],back[0][1]); printf("%c %c %c %c %c %c %c %c\n",leftt[1][0],leftt[1][1],font[1][0],font[1][1],rightt[1][0],rightt[1][1],back[1][0],back[1][1]); printf(" "); printf("%c %c\n",down[0][0],down[0][1]); printf(" "); printf("%c %c",down[1][0],down[1][1]); }
void getswapF(char (*data1)[maxn],char (*data2)[maxn],char (*data3)[maxn],char (*data4)[maxn]) { char tmp1 = data4[1][1]; char tmp2 = data4[0][1]; data4[0][1] = data3[0][0]; data4[1][1] = data3[0][1]; data3[0][1] = data2[0][0]; data3[0][0] = data2[1][0]; data2[0][0] = data1[1][0]; data2[1][0] = data1[1][1];
data1[1][0] = tmp1; data1[1][1] = tmp2; } void getswapf(char (*data1)[maxn],char (*data2)[maxn],char (*data3)[maxn],char (*data4)[maxn]) { char tmp1 = data1[1][0]; char tmp2 = data1[1][1]; data1[1][0] = data2[0][0]; data1[1][1] = data2[1][0]; data2[1][0] = data3[0][0]; data2[0][0] = data3[0][1]; data3[0][0] = data4[0][1]; data3[0][1] = data4[1][1]; data4[1][1] = tmp1; data4[0][1] = tmp2; } void getswapU(char (*data1)[maxn],char (*data2)[maxn],char (*data3)[maxn],char (*data4)[maxn]) { char tmp1 = data1[0][0]; char tmp2 = data1[0][1]; data1[0][0] = data2[0][0]; data1[0][1] = data2[0][1]; data2[0][0] = data3[0][0]; data2[0][1] = data3[0][1]; data3[0][0] = data4[0][0]; data3[0][1] = data4[0][1]; data4[0][0] = tmp1; data4[0][1] = tmp2; } void getswapR(char (*data1)[maxn],char (*data2)[maxn],char (*data3)[maxn],char (*data4)[maxn]) { char tmp1 = data1[0][1]; char tmp2 = data1[1][1]; data1[0][1] = data4[0][1]; data1[1][1] = data4[1][1]; data4[1][1] = data3[0][0]; data4[0][1] = data3[1][0]; data3[0][0] = data2[1][1]; data3[1][0] = data2[0][1]; data2[0][1] = tmp1; data2[1][1] = tmp2; } void getswapr(char (*data1)[maxn],char (*data2)[maxn],char (*data3)[maxn],char (*data4)[maxn]) { char tmp1 = data1[0][1]; char tmp2 = data1[1][1];
data1[0][1] = data2[0][1]; data1[1][1] = data2[1][1]; data2[0][1] = data3[1][0]; data2[1][1] = data3[0][0]; data3[1][0] = data4[0][1]; data3[0][0] = data4[1][1]; data4[0][1] = tmp1; data4[1][1] = tmp2; } void adjust(char (*data)[maxn],int op) { char tmp = data[0][0]; if(op == 1){ data[0][0] = data[1][0]; data[1][0] = data[1][1]; data[1][1] = data[0][1]; data[0][1] = tmp; }else{ data[0][0] = data[0][1]; data[0][1] = data[1][1]; data[1][1] = data[1][0]; data[1][0] = tmp; } } int main() { scanf("%s",op); for(int i = 0;i < strlen(op);++ i) { if(op[i] == 'F') { adjust(font,1); getswapF(top,rightt,down,leftt); } if(op[i] == 'f') { adjust(font,0); getswapf(top,rightt,down,leftt); } if(op[i] == 'u') { adjust(top,0); getswapU(rightt,font,leftt,back); } if(op[i] == 'U') { adjust(top,1); getswapU(back,leftt,font,rightt); } if(op[i] == 'R') { adjust(rightt,1); getswapR(font,top,back,down); } if(op[i] == 'r') { adjust(rightt,0); getswapr(font,top,back,down); } } printans(); return 0; }
|