|
@ -10,18 +10,17 @@ |
|
|
using namespace std; |
|
|
using namespace std; |
|
|
|
|
|
|
|
|
ofstream File_Output; |
|
|
ofstream File_Output; |
|
|
|
|
|
|
|
|
unsigned long long checked_code; |
|
|
unsigned long long checked_code; |
|
|
|
|
|
|
|
|
bool code_check(string str) { |
|
|
bool code_check(string str) { |
|
|
HRD_cal cal; |
|
|
HRD_cal cal; |
|
|
char code_str[10]; |
|
|
char code_str[10]; |
|
|
if (str.length() != 9) { |
|
|
if (str.length() != 9) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
for (unsigned int i = 0; i < str.length(); i++) { |
|
|
for (unsigned int i = 0; i < str.length(); i++) { |
|
|
code_str[i] = str[i]; |
|
|
code_str[i] = str[i]; |
|
|
} |
|
|
} |
|
|
code_str[9] = '\0'; |
|
|
code_str[9] = '\0'; |
|
|
checked_code = cal.Change_int(code_str); |
|
|
checked_code = cal.Change_int(code_str); |
|
|
return cal.Check_Code(checked_code); |
|
|
return cal.Check_Code(checked_code); |
|
@ -29,12 +28,12 @@ bool code_check(string str) { |
|
|
|
|
|
|
|
|
void show_case(string str) { |
|
|
void show_case(string str) { |
|
|
unsigned long long code; |
|
|
unsigned long long code; |
|
|
if (code_check(str) == false) { |
|
|
if (code_check(str) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
code = checked_code; |
|
|
code = checked_code; |
|
|
HRD_analy analy; |
|
|
HRD_analy analy; |
|
|
char output_char[3] = "&%"; |
|
|
char output_char[3] = "&%"; |
|
|
cout << endl; |
|
|
cout << endl; |
|
@ -45,16 +44,16 @@ void show_case(string str) { |
|
|
|
|
|
|
|
|
void show_case(string str, string width) { |
|
|
void show_case(string str, string width) { |
|
|
unsigned long long code; |
|
|
unsigned long long code; |
|
|
if (code_check(str) == false) { |
|
|
if (code_check(str) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
code = checked_code; |
|
|
code = checked_code; |
|
|
HRD_analy analy; |
|
|
HRD_analy analy; |
|
|
int square_width; |
|
|
int square_width; |
|
|
char output_char[3] = "&%"; |
|
|
char output_char[3] = "&%"; |
|
|
istringstream is(width); // 借用字符串流对象将string转为int
|
|
|
istringstream is(width); // 借用字符串流对象将string转为int
|
|
|
is >> square_width; |
|
|
is >> square_width; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
cout << "Code: " << analy.Change_str(code) << endl; |
|
|
cout << "Code: " << analy.Change_str(code) << endl; |
|
@ -65,11 +64,11 @@ void show_case(string str, string width) { |
|
|
void cal_case(string str) { |
|
|
void cal_case(string str) { |
|
|
unsigned long long code; |
|
|
unsigned long long code; |
|
|
vector <unsigned long long> dat; |
|
|
vector <unsigned long long> dat; |
|
|
if (code_check(str) == false) { |
|
|
if (code_check(str) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
HRD_cal cal; |
|
|
HRD_cal cal; |
|
|
code = checked_code; |
|
|
code = checked_code; |
|
|
cout << "Start code: " << cal.Change_str(code) << endl; |
|
|
cout << "Start code: " << cal.Change_str(code) << endl; |
|
@ -88,11 +87,11 @@ void cal_case(string str) { |
|
|
void cal_case(string str, string File_name) { |
|
|
void cal_case(string str, string File_name) { |
|
|
unsigned long long code; |
|
|
unsigned long long code; |
|
|
vector <unsigned long long> dat; |
|
|
vector <unsigned long long> dat; |
|
|
if (code_check(str) == false) { |
|
|
if (code_check(str) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
HRD_cal cal; |
|
|
HRD_cal cal; |
|
|
code = checked_code; |
|
|
code = checked_code; |
|
|
cout << "Start code: " << cal.Change_str(code) << endl; |
|
|
cout << "Start code: " << cal.Change_str(code) << endl; |
|
@ -122,18 +121,18 @@ void cal_case(string str, string File_name) { |
|
|
void cal_target(string str_1, string str_2) { |
|
|
void cal_target(string str_1, string str_2) { |
|
|
unsigned long long code, target; |
|
|
unsigned long long code, target; |
|
|
vector <unsigned long long> dat; |
|
|
vector <unsigned long long> dat; |
|
|
if (code_check(str_1) == false) { |
|
|
if (code_check(str_1) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
code = checked_code; |
|
|
code = checked_code; |
|
|
if (code_check(str_2) == false) { |
|
|
if (code_check(str_2) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
target = checked_code; |
|
|
target = checked_code; |
|
|
HRD_cal cal; |
|
|
HRD_cal cal; |
|
|
cout << "Start code: " << cal.Change_str(code) << endl; |
|
|
cout << "Start code: " << cal.Change_str(code) << endl; |
|
|
cout << "Target code: " << cal.Change_str(target) << endl; |
|
|
cout << "Target code: " << cal.Change_str(target) << endl; |
|
@ -152,18 +151,18 @@ void cal_target(string str_1, string str_2) { |
|
|
void cal_target(string str_1, string str_2, string File_name) { |
|
|
void cal_target(string str_1, string str_2, string File_name) { |
|
|
unsigned long long code, target; |
|
|
unsigned long long code, target; |
|
|
vector <unsigned long long> dat; |
|
|
vector <unsigned long long> dat; |
|
|
if (code_check(str_1) == false) { |
|
|
if (code_check(str_1) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
code = checked_code; |
|
|
code = checked_code; |
|
|
if (code_check(str_2) == false) { |
|
|
if (code_check(str_2) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
target = checked_code; |
|
|
target = checked_code; |
|
|
HRD_cal cal; |
|
|
HRD_cal cal; |
|
|
cout << "Start code: " << cal.Change_str(code) << endl; |
|
|
cout << "Start code: " << cal.Change_str(code) << endl; |
|
|
cout << "Target code: " << cal.Change_str(target) << endl; |
|
|
cout << "Target code: " << cal.Change_str(target) << endl; |
|
@ -193,11 +192,11 @@ void cal_target(string str_1, string str_2, string File_name) { |
|
|
void cal_group(string str) { |
|
|
void cal_group(string str) { |
|
|
unsigned long long code; |
|
|
unsigned long long code; |
|
|
vector <unsigned long long> dat; |
|
|
vector <unsigned long long> dat; |
|
|
if (code_check(str) == false) { |
|
|
if (code_check(str) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
HRD_cal cal; |
|
|
HRD_cal cal; |
|
|
code = checked_code; |
|
|
code = checked_code; |
|
|
cout << "Start code: " << cal.Change_str(code) << endl; |
|
|
cout << "Start code: " << cal.Change_str(code) << endl; |
|
@ -209,11 +208,11 @@ void cal_group(string str) { |
|
|
void cal_group(string str, string File_name) { |
|
|
void cal_group(string str, string File_name) { |
|
|
unsigned long long code; |
|
|
unsigned long long code; |
|
|
vector <unsigned long long> dat; |
|
|
vector <unsigned long long> dat; |
|
|
if (code_check(str) == false) { |
|
|
if (code_check(str) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
HRD_cal cal; |
|
|
HRD_cal cal; |
|
|
code = checked_code; |
|
|
code = checked_code; |
|
|
cout << "Start code: " << cal.Change_str(code) << endl; |
|
|
cout << "Start code: " << cal.Change_str(code) << endl; |
|
@ -235,11 +234,11 @@ void cal_group(string str, string File_name) { |
|
|
void analy_case(string str, bool quiet) { |
|
|
void analy_case(string str, bool quiet) { |
|
|
unsigned long long code; |
|
|
unsigned long long code; |
|
|
vector <unsigned long long> dat; |
|
|
vector <unsigned long long> dat; |
|
|
if (code_check(str) == false) { |
|
|
if (code_check(str) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
HRD_analy analy; |
|
|
HRD_analy analy; |
|
|
code = checked_code; |
|
|
code = checked_code; |
|
|
cout << "Start code: " << analy.Change_str(code) << endl; |
|
|
cout << "Start code: " << analy.Change_str(code) << endl; |
|
@ -252,11 +251,11 @@ void analy_case(string str, bool quiet) { |
|
|
void analy_case(string str, string File_name, bool quiet) { |
|
|
void analy_case(string str, string File_name, bool quiet) { |
|
|
unsigned long long code; |
|
|
unsigned long long code; |
|
|
vector <unsigned long long> dat; |
|
|
vector <unsigned long long> dat; |
|
|
if (code_check(str) == false) { |
|
|
if (code_check(str) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
HRD_analy analy; |
|
|
HRD_analy analy; |
|
|
code = checked_code; |
|
|
code = checked_code; |
|
|
cout << "Start code: " << analy.Change_str(code) << endl; |
|
|
cout << "Start code: " << analy.Change_str(code) << endl; |
|
@ -276,11 +275,11 @@ void analy_case(string str, string File_name, bool quiet) { |
|
|
void analy_group(string str, string File_name_1, string File_name_2, bool is_all) { |
|
|
void analy_group(string str, string File_name_1, string File_name_2, bool is_all) { |
|
|
unsigned long long code; |
|
|
unsigned long long code; |
|
|
vector <unsigned long long> dat; |
|
|
vector <unsigned long long> dat; |
|
|
if (code_check(str) == false) { |
|
|
if (code_check(str) == false) { |
|
|
cout << "code error" << endl; |
|
|
cout << "code error" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
HRD_group group; |
|
|
HRD_group group; |
|
|
code = checked_code; |
|
|
code = checked_code; |
|
|
cout << "Start code: " << group.Change_str(code) << endl; |
|
|
cout << "Start code: " << group.Change_str(code) << endl; |
|
@ -395,103 +394,103 @@ void parameter_err() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) { |
|
|
int main(int argc, char* argv[]) { |
|
|
cout << endl << "Klotski engine by Dnomd343" << endl; |
|
|
cout << endl << "Klotski engine by Dnomd343" << endl; |
|
|
if (argc <= 1) { |
|
|
if (argc <= 1) { |
|
|
cout << "no parameter" << endl; |
|
|
cout << "no parameter" << endl; |
|
|
cout << "You can try \"--help\" for more information" << endl; |
|
|
cout << "You can try \"--help\" for more information" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
string parameter; |
|
|
string parameter; |
|
|
parameter = argv[1]; |
|
|
parameter = argv[1]; |
|
|
if (parameter == "--show") { |
|
|
if (parameter == "--show") { |
|
|
if (argc == 3) { |
|
|
if (argc == 3) { |
|
|
show_case(argv[2]); |
|
|
show_case(argv[2]); |
|
|
} else if (argc == 4) { |
|
|
} else if (argc == 4) { |
|
|
show_case(argv[2], argv[3]); |
|
|
show_case(argv[2], argv[3]); |
|
|
} else { |
|
|
} else { |
|
|
parameter_err(); |
|
|
parameter_err(); |
|
|
} |
|
|
} |
|
|
} else if (parameter == "--cal") { |
|
|
} else if (parameter == "--cal") { |
|
|
if (argc == 3) { |
|
|
if (argc == 3) { |
|
|
cal_case(argv[2]); |
|
|
cal_case(argv[2]); |
|
|
} else if (argc == 4) { |
|
|
} else if (argc == 4) { |
|
|
cal_case(argv[2], argv[3]); |
|
|
cal_case(argv[2], argv[3]); |
|
|
} else { |
|
|
} else { |
|
|
parameter_err(); |
|
|
parameter_err(); |
|
|
} |
|
|
} |
|
|
} else if (parameter == "--cal-target") { |
|
|
} else if (parameter == "--cal-target") { |
|
|
if (argc == 4) { |
|
|
if (argc == 4) { |
|
|
cal_target(argv[2], argv[3]); |
|
|
cal_target(argv[2], argv[3]); |
|
|
} else if (argc == 5) { |
|
|
} else if (argc == 5) { |
|
|
cal_target(argv[2], argv[3], argv[4]); |
|
|
cal_target(argv[2], argv[3], argv[4]); |
|
|
} else { |
|
|
} else { |
|
|
parameter_err(); |
|
|
parameter_err(); |
|
|
} |
|
|
} |
|
|
} else if (parameter == "--group") { |
|
|
} else if (parameter == "--group") { |
|
|
if (argc == 3) { |
|
|
if (argc == 3) { |
|
|
cal_group(argv[2]); |
|
|
cal_group(argv[2]); |
|
|
} else if (argc == 4) { |
|
|
} else if (argc == 4) { |
|
|
cal_group(argv[2], argv[3]); |
|
|
cal_group(argv[2], argv[3]); |
|
|
} else { |
|
|
} else { |
|
|
parameter_err(); |
|
|
parameter_err(); |
|
|
} |
|
|
} |
|
|
} else if (parameter == "--analy") { |
|
|
} else if (parameter == "--analy") { |
|
|
if (argc == 3) { |
|
|
if (argc == 3) { |
|
|
analy_case(argv[2], false); |
|
|
analy_case(argv[2], false); |
|
|
} else if (argc == 4) { |
|
|
} else if (argc == 4) { |
|
|
analy_case(argv[2], argv[3], false); |
|
|
analy_case(argv[2], argv[3], false); |
|
|
} else { |
|
|
} else { |
|
|
parameter_err(); |
|
|
parameter_err(); |
|
|
} |
|
|
} |
|
|
} else if (parameter == "--analy-quiet") { |
|
|
} else if (parameter == "--analy-quiet") { |
|
|
if (argc == 4) { |
|
|
if (argc == 4) { |
|
|
analy_case(argv[2], argv[3], true); |
|
|
analy_case(argv[2], argv[3], true); |
|
|
} else { |
|
|
} else { |
|
|
parameter_err(); |
|
|
parameter_err(); |
|
|
} |
|
|
} |
|
|
} else if (parameter == "--analy-group") { |
|
|
} else if (parameter == "--analy-group") { |
|
|
if (argc == 5) { |
|
|
if (argc == 5) { |
|
|
analy_group(argv[2], argv[3], argv[4], false); |
|
|
analy_group(argv[2], argv[3], argv[4], false); |
|
|
} else { |
|
|
} else { |
|
|
parameter_err(); |
|
|
parameter_err(); |
|
|
} |
|
|
} |
|
|
} else if (parameter == "--analy-group-integral") { |
|
|
} else if (parameter == "--analy-group-integral") { |
|
|
if (argc == 5) { |
|
|
if (argc == 5) { |
|
|
analy_group(argv[2], argv[3], argv[4], true); |
|
|
analy_group(argv[2], argv[3], argv[4], true); |
|
|
} else { |
|
|
} else { |
|
|
parameter_err(); |
|
|
parameter_err(); |
|
|
} |
|
|
} |
|
|
} else if (parameter == "--analy-multi-group") { |
|
|
} else if (parameter == "--analy-multi-group") { |
|
|
if (argc == 5) { |
|
|
if (argc == 5) { |
|
|
analy_multi_group(argv[2], argv[3], argv[4], false); |
|
|
analy_multi_group(argv[2], argv[3], argv[4], false); |
|
|
} else { |
|
|
} else { |
|
|
parameter_err(); |
|
|
parameter_err(); |
|
|
} |
|
|
} |
|
|
} else if (parameter == "--analy-multi-group-integral") { |
|
|
} else if (parameter == "--analy-multi-group-integral") { |
|
|
if (argc == 5) { |
|
|
if (argc == 5) { |
|
|
analy_multi_group(argv[2], argv[3], argv[4], true); |
|
|
analy_multi_group(argv[2], argv[3], argv[4], true); |
|
|
} else { |
|
|
} else { |
|
|
parameter_err(); |
|
|
parameter_err(); |
|
|
} |
|
|
} |
|
|
} else if (parameter == "--all") { |
|
|
} else if (parameter == "--all") { |
|
|
if (argc == 2) { |
|
|
if (argc == 2) { |
|
|
find_all(); |
|
|
find_all(); |
|
|
} else { |
|
|
} else { |
|
|
parameter_err(); |
|
|
parameter_err(); |
|
|
} |
|
|
} |
|
|
} else if (parameter == "--all-code") { |
|
|
} else if (parameter == "--all-code") { |
|
|
if (argc == 3) { |
|
|
if (argc == 3) { |
|
|
find_all_code(argv[2]); |
|
|
find_all_code(argv[2]); |
|
|
} else { |
|
|
} else { |
|
|
parameter_err(); |
|
|
parameter_err(); |
|
|
} |
|
|
} |
|
|
} else if (parameter == "--help") { |
|
|
} else if (parameter == "--help") { |
|
|
show_help(); |
|
|
show_help(); |
|
|
} else { |
|
|
} else { |
|
|
cout << "unknow parameter" << endl; |
|
|
cout << "unknow parameter" << endl; |
|
|
cout << "You can try \"--help\" for more information" << endl; |
|
|
cout << "You can try \"--help\" for more information" << endl; |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
} |
|
|
} |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|