#include stdio.h
class TuiLi //Inference class
{
//Private method part
protected:
SYSTEMTIME TIME; //Standard system time storage structure with 8 members and 16 bytes
struct FZ
{
int ys;
int yp;
int gj;
int cw;
int yl;
};//House attribute structure
FZ Fz[5];//Define 5 houses
int Biao[120][5];//Define combination table
int gj,ys,yl,cw,yp;//Combination flag
int sz[25];
//Solve Sudoku with
int sudu[81]; //Record backtracking path with
bool sudu_ji[81]; //Used to mark the value indicated by the question
int SD[9][9]; //Sudoku chessboard
//Solve N queens problem
int N;//Used to input the scale of the queen problem. In this example, only 33 queens can be solved because of memory allocation. Changing the memory allocation size can increase the scale of the problem.
int hh[1024]; //Record the backtracking path for solving the 33 queens problem at most
int HH[33][33];//Queen problem chessboard
//Public method part
public:
TuiLi(void);
~TuiLi(void);
void init_biao(void);//Initialize the combination table
void print(void);//Screen output
void gx(void);//Refresh the reasoning result
int OK(void);//Inference pruning condition
int go(void);//Main entry method for reasoning questions
int ok_sd(void);//Sudoku pruning condition
int go_sd(void);//Solve the population point of Sudoku
void sd_in(void);//Board data input
void SD_in(void);//Get the question information
void sd_out(void);//Board data output
void sd_print(void);//Screen output result
int ok_hh(int m);//Queen problem pruning function
int ok_hh_sc(void);//Final test
int go_hh(void); //Queen problem entry point
void hh_init(void);//Initialize chessboard data
void hh_out(void);//Chessboard data refresh
void hh_print(void);//Output result
};
Reference address:Try to use backtracking to solve reasoning problems
class TuiLi //Inference class
{
//Private method part
protected:
SYSTEMTIME TIME; //Standard system time storage structure with 8 members and 16 bytes
struct FZ
{
int ys;
int yp;
int gj;
int cw;
int yl;
};//House attribute structure
FZ Fz[5];//Define 5 houses
int Biao[120][5];//Define combination table
int gj,ys,yl,cw,yp;//Combination flag
int sz[25];
//Solve Sudoku with
int sudu[81]; //Record backtracking path with
bool sudu_ji[81]; //Used to mark the value indicated by the question
int SD[9][9]; //Sudoku chessboard
//Solve N queens problem
int N;//Used to input the scale of the queen problem. In this example, only 33 queens can be solved because of memory allocation. Changing the memory allocation size can increase the scale of the problem.
int hh[1024]; //Record the backtracking path for solving the 33 queens problem at most
int HH[33][33];//Queen problem chessboard
//Public method part
public:
TuiLi(void);
~TuiLi(void);
void init_biao(void);//Initialize the combination table
void print(void);//Screen output
void gx(void);//Refresh the reasoning result
int OK(void);//Inference pruning condition
int go(void);//Main entry method for reasoning questions
int ok_sd(void);//Sudoku pruning condition
int go_sd(void);//Solve the population point of Sudoku
void sd_in(void);//Board data input
void SD_in(void);//Get the question information
void sd_out(void);//Board data output
void sd_print(void);//Screen output result
int ok_hh(int m);//Queen problem pruning function
int ok_hh_sc(void);//Final test
int go_hh(void); //Queen problem entry point
void hh_init(void);//Initialize chessboard data
void hh_out(void);//Chessboard data refresh
void hh_print(void);//Output result
};
Previous article:Backtracking algorithm 1
Next article:Chapter 15 XOR and NOT (X86 Assembly Tutorial)
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- Power supply control principle of three-phase fuel pump used in Mercedes-Benz passenger cars
- Review summary: Free review of Fudan Micro FM33LG0 series, Winsilver chip
- ESP32-S2-Saola-1 calculates pi
- DCDC H-bridge circuit, what is the principle of boost and buck?
- How to measure positive and negative 1.5V signals using a single power supply system?
- [Zhongke Bluexun AB32VG1 RISC-V evaluation board] Current and voltage detection project development
- Complete list of motor model parameters, no longer worried about not understanding the motor model
- Learn about enhanced eCall car design in one article
- CC2640R2F as master control for DHT11
- HTS221 MakeCode extension (driver)