This repository has been archived by the owner on Jun 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCubeMain.cpp
85 lines (69 loc) · 1.5 KB
/
CubeMain.cpp
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
#include "CubeSolver.cpp"
#include <windows.h>
#include <cstdio>
using namespace std;
namespace CO {
HANDLE h;
WORD wOldColorAttrs;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
const char *opName[] = {
"U",
"B",
"R",
"F",
"L",
"D",
"Ui",
"Bi",
"Ri",
"Fi",
"Li",
"Di"
};
WORD color[] = {
FOREGROUND_RED,
FOREGROUND_GREEN,
FOREGROUND_BLUE,
FOREGROUND_RED | FOREGROUND_GREEN,
FOREGROUND_RED | FOREGROUND_BLUE,
FOREGROUND_BLUE | FOREGROUND_GREEN,
BACKGROUND_RED,
BACKGROUND_GREEN,
BACKGROUND_BLUE,
BACKGROUND_RED | BACKGROUND_GREEN,
BACKGROUND_RED | BACKGROUND_BLUE,
BACKGROUND_BLUE | BACKGROUND_GREEN,
};
void printOp(Op o) {
SetConsoleTextAttribute(h, color[(int)o]);
printf("%s", opName[(int)o]);
SetConsoleTextAttribute(h, wOldColorAttrs);
putchar(' ');
}
void initCO() {
h = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(h, &csbiInfo);
wOldColorAttrs = csbiInfo.wAttributes;
}
}
using CO::printOp;
using CO::initCO;
char F[6][10];
char *Fptr[] = { F[0], F[1], F[2], F[3], F[4], F[5] };
int main() {
initCO();
scanf("%s", F[(int)Face::F]);
scanf("%s", F[(int)Face::B]);
scanf("%s", F[(int)Face::R]);
scanf("%s", F[(int)Face::L]);
scanf("%s", F[(int)Face::U]);
scanf("%s", F[(int)Face::D]);
Cube status = Cube(Fptr);
auto solution = Solve(&status);
int cnt = 0;
for (auto i : solution) {
printOp(i);
//if (!((++cnt) % 5)) putchar('\n');
}
return 0;
}