-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
90 lines (85 loc) · 1.75 KB
/
test.cpp
File metadata and controls
90 lines (85 loc) · 1.75 KB
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
86
87
88
89
90
//
// Created by WADwi on 2021/3/2.
//
#include "BPuzzle.h"
#include "BPuzzleGen.h"
#include <unistd.h>
#include <time.h>
//#include <string>
void case1(){
char t[100];
printf("CNF file path:");
scanf("%s", t);
int t1 = clock();
DPLL dpll(t);
dpll.origin.jiexi();
if (dpll.solve() != unholdable) {
for (int i = 0; i < dpll.result.literals_len; i++) {
printf("变元%d的值为%d\n", i + 1, dpll.result.literals[i].val);
}
};
printf("Print to Res file?(Y/N)\n");
getchar();
char c;
scanf("%c", &c);
int t2 = clock();
switch (c) {
case 'Y':
dpll.print_res(t, (float)(t2 - t1) / CLOCKS_PER_SEC * 1000);
break;
default:
break;
}
printf("%f ms", (double)(t2 - t1) / CLOCKS_PER_SEC * 1000);
}
void case2(){
char t[100];
int size;
printf("Puzzle file path & size:");
scanf("%s %d", t, &size);
int t1 = clock();
BPuzzle bpuzzle(t, size);
// bpuzzle.sat.origin.to_string();
if(bpuzzle.solve() != unholdable){
bpuzzle.print();
};
int t2 = clock();
printf("%f ms", (double)(t2 - t1) / CLOCKS_PER_SEC * 1000);
}
void case3(){
char t[100];
int size;
printf("Puzzle file path & size:");
scanf("%s %d", t, &size);
int t1 = clock();
BPuzzleGen generator(t, size);
generator.generate();
generator.print();
generator.fsave("/home/wings/puzzle");
BPuzzle bpuzzle("/home/wings/puzzle", size);
if(bpuzzle.solve() != unholdable){
bpuzzle.print();
};
int t2 = clock();
printf("%f ms", (double)(t2 - t1) / CLOCKS_PER_SEC * 1000);
}
int main(int argc, char *argv[]) {
int c;
printf("1 for solve CNF\n2 for solve Puzzzle\n3 for generate Puzzle\n");
c = getc(stdin);
switch (c) {
case '1':
case1();
break;
case '2':
case2();
break;
case '3':
case3();
break;
default:
printf("wrong input!");
break;
}
return 0;
}