#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int cube[6][6] = {{0, 1, 2, 3, 4, 5}, {1, 5, 2, 3, 0, 4}, {2, 1, 5, 0, 4, 3}, {3, 1, 0, 5, 4, 2}, {4, 3, 0, 5, 2, 1}, {5, 1, 3, 2, 4, 0}};
char a[10], b[10];
bool check() {
for (int i = 0; i < 6; i++) {
char temp[10];
for (int j = 0; j < 6; j++) {
temp[j] = a[cube[i][j]];
}
for (int k = 0; k < 4; k++) {
char t;
t = temp[1];
temp[1] = temp[2];
temp[2] = temp[4];
temp[4] = temp[3];
temp[3] = t;
if (strcmp(temp, b) == 0) return true;
}
}
return false;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s;
while (cin >> s) {
for (int i = 0; i < 6; i++) {
a[i] = s[i];
b[i] = s[6 + i];
}
if (check()) cout << "TRUE" << endl;
else cout << "FALSE" << endl;
}
return 0;
}
这个代码一直AC不了,Udebug上也测过了,数据全对。然后我试了一下给temp数组加了初始化,就A了;接着试了一下把temp数组放到全局里面(无初始化),也通过了。为什么就是函数内的会出问题,求教!