You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
739 B
31 lines
739 B
1 year ago
|
#include "SudokuMatrix.h"
|
||
|
|
||
|
SudokuMatrix* CreateMatrix(){
|
||
|
SudokuMatrix *matrix = (SudokuMatrix*)malloc(sizeof(SudokuMatrix));
|
||
|
// 初始化这个数组里的数为0
|
||
|
for (int i=0;i<9;i++){
|
||
|
for (int j=0;j<9;j++){
|
||
|
matrix->matrix[i][j] = 0;
|
||
|
}
|
||
|
}
|
||
|
return matrix;
|
||
|
}
|
||
|
|
||
|
SudokuMatrix* CreateMatrixFromArray(int matrix[9][9]){
|
||
|
SudokuMatrix *newMatrix = CreateMatrix();
|
||
|
// 拷贝内部的数组为输入的数组
|
||
|
for(int i=0; i<9; i++){
|
||
|
for(int j=0; j<9; j++){
|
||
|
newMatrix->matrix[i][j] = matrix[i][j];
|
||
|
}
|
||
|
}
|
||
|
return newMatrix;
|
||
|
}
|
||
|
|
||
|
void DeleteMatrix(SudokuMatrix *matrix){
|
||
|
// 释放整个结构体
|
||
|
if (matrix != NULL)
|
||
|
{
|
||
|
free(matrix);
|
||
|
}
|
||
|
}
|