1、Github地址:https://github.com/YangSlim/031702243
2、PSP表格
PSP2.1 | Personal Software Process Stages | 预估耗时(分钟) | 实际耗时(分钟) |
Planning | 计划 | 1h | 1h |
Estimate | 估计这个任务需要多少时间 | 20.5h | 21.5h |
Development | 开发 | 5h | 4h |
Analysis | 需求分析 (包括学习新技术) | 2h | 5h |
Design Spec | 生成设计文档 | 1h | 1h |
Design Review | 设计复审 | 0.5h | 0.5h |
Coding Standard | 代码规范 (为目前的开发制定合适的规范) | 1h | 0.5h |
Design | 具体设计 | 1h | 0.5h |
Coding | 具体编码 | 1h | 1h |
Code Review | 代码复审 | 1h | 1h |
Test | 测试(自我测试,修改代码,提交修改) | 2h | 1.5h |
Reporting | 报告 | 2h | 2h |
Test Repor | 测试报告 | 0.5h | 1h |
Size Measurement | 计算工作量 | 0.5h | 0.5h |
Postmortem & Process Improvement Plan | 事后总结, 并提出过程改进计划 | 2h | 2h |
合计 | 20.5h | 21.5h |
/* b为x所在的小九宫格左顶点竖坐标 */
int b = x / m / row * row;
/* c为x所在的小九宫格左顶点横坐标 */
int c = x % m / col * col;
for (i = b; i < b + row; i++)
{
for (j = c; j < c + col; j++)
{
if (a[i][j] == key)
{
return false;
}
}
}
return true;
}
###对行和列进行判断完,直接调用对宫判断的函数
bool judge_row_col(int x, int key)/判断数独的每一列每一行是否重复/
{
int row = x / m;
int col = x % m;
for (int i = 0; i < m; i++)/判断行 /
{
if (a[row][i] == key)
{
return false;
}
}
for (int i = 0; i < m; i++)/判断列/
{
if (a[i][col] == key)
{
return false;
}
}
if (m == 4)/4宫格/
{
if (judge_palace(x, 2, 2, key))/* 宫的大小2*2 */
{
return true;
}
return false;
}
else if (m == 6)/*6宫格*/
{
if (judge_palace(x, 2, 3, key))/* 宫的大小2*3 */
{
return true;
}
return false;
}
else if (m == 8)/*8宫格*/
{
if (judge_palace(x, 4, 2, key))/* 宫的大小4*2 */
{
return true;
}
return false;
}
else if (m == 9)/*9宫格*/
{
if (judge_palace(x, 3, 3, key))/* 宫的大小3*3 */
{
return true;
}
return false;
}
return true;
}
###DFS遍历填入数字
void DFS(int x)/* 深搜构造数独 /
{
if (sign)/如果已经完成 直接返回/
{
return;
}
if (x == m * m)/ 说明所有的都符合,数独求解完毕,退出递归 /
{
print();
sign = 1;
return;
}
int row = x / m;
int col = x % m;
if (a[row][col] != 0)/当前位置不为空则判断下一空/
{
DFS(x + 1);
}
else
{
for (int i = 1; i <= m; i++)
{
if (judge_row_col(x, i))
{
a[row][col] = i;
DFS(x + 1);
/ 如果构造不成功,还原当前位 */
a[row][col] = 0;
}
}
}
}
##测试结果
###3宫格

###4宫格

###5宫格

###6宫格

###7宫格

###8宫格

###9宫格

###性能分析

##总结
这次作业花了很多时间在文件的读取和输出上面,因为之前没有在命令行输入参数然后运行代码,走了不少弯路。还有就是熟悉了怎么在本地上传文件到Github。