习题4-4(uva-253)

#include <iostream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>


#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
char input[36],a[7],b[7],temp[7];

void TurnRight(char* in) {
	for (int i = 0; i < 6; ++i)temp[i] = in[i];

	in[1] = temp[2];
	in[2] = temp[4];
	in[3] = temp[1];
	in[4] = temp[3];
}
void TrunLeft(char* in) {
	for (int i = 0; i < 3; ++i)TurnRight(in);
}
void TurnDown(char* in) {
	for (int i = 0; i < 6; ++i)temp[i] = in[i];
	in[0] = temp[4];
	in[1] = temp[0];
	in[4] = temp[5];
	in[5] = temp[1];
}
void TrunUp(char* in) {
	for (int i = 0; i < 3; ++i)TurnDown(in);
}
bool IsOk(char* a, char* b) {
	if (a[0] == b[0]) {
		for (int i = 0; i < 4; ++i) {
			if (strncmp(a, b, 6) == 0) return true;
			TrunLeft(a);
		}
	}
	return false;
}
//六个面分别作为1号  旋转是否能够得到b
bool Check(char* a, char* b) {
	char base[7];
	memmove(base, a, 6);
	if (IsOk(base, b)) return true;

	memmove(base, a, 6); TrunLeft(base); TrunUp(base);
	if (IsOk(base, b)) return true;

	memmove(base, a, 6); TurnRight(base); TrunUp(base);
	if (IsOk(base, b)) return true;

	memmove(base, a, 6); TurnDown(base);
	if (IsOk(base, b)) return true;

	memmove(base, a, 6); TrunUp(base);
	if (IsOk(base, b)) return true;

	memmove(base, a, 6); TurnDown(base); TurnDown(base);
	if (IsOk(base, b)) return true;

	return false;
}
int main()
{
	while (cin >> input) {
		memmove(a, input, 6);
		memmove(b, input + 6, 6);
		if (Check(a, b)) cout << "TRUE" << endl;
		else cout << "FALSE" << endl;
	}
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值