Tag: 数独

论数独解决

有人可以帮我理解这个解决方案 : Initialize 2D array with 81 empty grids (nx = 9, ny = 9) Fill in some empty grid with the known values Make an original copy of the array Start from top left grid (nx = 0, ny = 0), check if grid is empty if (grid is empty) { assign the empty […]

随机数独生成

我正在编写一个函数,可以为模拟项目生成随机的数独游戏; 这个函数将生成的单元格数作为argoument,然后生成要放入这些单元格的单元格和数字的索引。 我在生成单元格索引时遇到问题,我不是编程专家,我找不到一个好的例程来生成索引,并且检查不是两次或更多次的同一索引。 function是: void gen_puzzle(int quanti) { if(quanti>81) exit(1); indexes* ij=new indexes[quanti]; int f,g,k, controllo=1; do { for(f=0; f<9; f++) for(g=0; g<9; g++) { puzzle[f][g].num=0;//puts 0 in the sudoku puzzle puzzle[f][g].p=0; } //////////////section to improve out: srand(int(time(0)+clock())); for(k=0; k<quanti; k++) ij[k].i=casuale()-1, ij[k].j=casuale()-1;//generates random indexes of sudoku cells where put random nubers for(f=0; f<quanti; f++) […]