-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsudoku.h
executable file
·89 lines (69 loc) · 2.11 KB
/
sudoku.h
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
/*************************************************************************
> File Name: sudoku.h
> Author:
> Mail:
> Created Time: Tue 28 Mar 2017 09:25:19 PM CST
************************************************************************/
#ifndef _SUDOKU_H
#define _SUDOKU_H
#include<vector>
#include<set>
#include<cstdlib>
typedef std::vector<int> vint;
typedef std::vector<vint> vvint;
typedef std::set<std::pair<int, int> > spairii;
class SudoKu
{
private:
const int hardclass;
int checktemp;//临时变量,不再一直调用vvnum[][]
vvint vvnum;
vvint result;
void change_Number();//初始化9×9格子
//5个初始化算法
void change_value(int lhs,int rhs);
void swap_col(int lhs,int rhs);
void swap_row(int lhs,int rhs);
void swap_threecol(int lhs,int rhs);
void swap_threerow(int lhs,int rhs);
int onlyone(int a,int b);
public:
~SudoKu(){}
explicit SudoKu(int a);
const vint & operator[](int a)const{return vvnum[a];}
vint & operator[](int a){return vvnum[a];}
vvint copy();
void set(const vvint& vec);
const vvint& getresult(){return result;}
std::pair<int,int> help();
//same num check
void check1(int a, int b, spairii &vecpr);
//only number check
void check2(int a, int b, spairii &vecpr);
bool haswrong(int a, int b);
bool haswrong2(int a, int b);
bool checkwin();
//void show();
};
//Assist class
class GameLevel
{
private:
const int level;
std::vector<std::vector<bool> >defaultshow;//9×9的显示方式
vint ways;//显示方式,每行显示出来几个
void setlevel();//所有设置,调用下两个函数
void sayEasyWays();//设置成员ways
void sayMediumWays();
void sayHardWays();
void sayHellWays();
void generate_map();//设置defaultshow,调用下一函数
void changeRow(std::vector<bool>&,int);
public:
const std::vector<bool>& operator[](int a)const{return defaultshow[a];}
explicit GameLevel(int a):level(a),
defaultshow(9,std::vector<bool>(9,0)),ways(9,0)
{setlevel();generate_map();}
//void show();
};
#endif