include mainwindow include ui_mainwindow struct wing int from int out

 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
struct wing
{
int from;
int out;
int to;
};
static int status=1;
static wing automate[4][3]={{{1,1,2},{2,4,3},{3,2,4}},
{{1,2,2},{2,3,3},{3,4,4}},
{{1,3,2},{2,3,1},{3,4,4}},
{{1,1,4},{2,4,2},{3,2,1}}};
int GetMove(int from, int to)
{
--from;
for (int i = 0; i < 3; ++i)
if (automate[from][i].from == to)
{
status = automate[from][i].to;
return automate[from][i].out;
}
return -1;
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->label_3->setPixmap(QPixmap("D1.png"));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QString str,str2;
int i = GetMove(status,1);
str.setNum(i);
str2.setNum(status);
ui->lineEdit->setText(str);
ui->lineEdit_2->setText(str2);
}
void MainWindow::on_pushButton_2_clicked()
{
QString str,str2;
int i = GetMove(status,2);
str.setNum(i);
str2.setNum(status);
ui->lineEdit->setText(str);
ui->lineEdit_2->setText(str2);
}
void MainWindow::on_pushButton_3_clicked()
{
QString str,str2;
int i = GetMove(status,3);
str.setNum(i);
str2.setNum(status);
ui->lineEdit->setText(str);
ui->lineEdit_2->setText(str2);
}