1. 程式人生 > >演算法競賽入門經典第四章習題4-4 Cube painting UVA

演算法競賽入門經典第四章習題4-4 Cube painting UVA

#include<iostream>
#include<string>
#include<cstring>
#pragma warning(disable:4996)
using namespace std;

int main() {
#ifdef _DEBUG
    //freopen("in", "rb", stdin);
    //freopen("out", "wb", stdout);
#endif // _DEBUG    
    string A[24] = { "123456","135246","154326","142536",
                    "214365"
,"246135","263415","231645", "312564","326154","365214","351624", "421653","415263","456123","462513", "513462","536142","564312","541632", "624351","645231","653421","632541" }; string s, t; while (cin >> s) { bool
is_true=false; t = string(s, 0, 6); s = string(s, 6, 12); for (int i = 0; i < 24; ++i) { is_true = true; for(int j=0;j<6;++j) if (t[j] != s[A[i][j] - '1']) { is_true = false; break; } if
(is_true) break; } if (is_true) cout << "TRUE" << endl; else cout << "FALSE" << endl; } }