-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchessboardproblem.h
More file actions
60 lines (47 loc) · 1.52 KB
/
chessboardproblem.h
File metadata and controls
60 lines (47 loc) · 1.52 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
#ifndef CHESSBOARDPROBLEM_H
#define CHESSBOARDPROBLEM_H
#include <QObject>
// 定义点
typedef struct point {
int x, y; // 初始点的横坐标和纵坐标
int index; // 方向指针
int weight; // 该点的权值
point() {} // 默认构造函数
} point;
#define MAX_STACK_SIZE 70
// 定义栈
typedef struct Stack {
point *elem;
int base, top;
} Stack;
class ChessBoardProblem : public QObject
{
Q_OBJECT
public:
explicit ChessBoardProblem(QObject *parent = nullptr);
ChessBoardProblem(int start_x, int start_y);
static int Board[8][8]; // 棋盘
static const int MOVEX[8];
static const int MOVEY[8];
static Stack s;
static int order;
static int startX, startY; // 起始点
static void initStack(Stack &s);
static void push(Stack &s, point p);
static void pop(Stack &s);
static point getTop(Stack s);
static bool isEmpty(Stack s);
static void swap(point &a, point &b);
static int Partition(point direction[], int low, int high);
static void QSort(point direction[], int low, int high);
static void QuickSort(point direction[], int size);
static bool check(int x, int y);
static void forward(point &now, point direction[], int &index);
static void backward(point &now, int &index);
static int calculateTheWeight(int x, int y);
static void chessBoardProblem(int startX, int startY);
static void initState();
signals:
public slots:
};
#endif // CHESSBOARDPROBLEM_H