@M1saki
2017-09-07T18:57:42.000000Z
字数 2335
阅读 1203
软工实践
相关要求:第二次作业——个人项目实战
github:传送门
| PSP2.1 | Personal Software Process Stages | 预估耗时(分钟) | 实际耗时(分钟) |
|---|---|---|---|
| Planning | 计划 | 30 | 25 |
| · Estimate | · 估计这个任务需要多少时间 | 30 | 25 |
| Development | 开发 | 605 | 445 |
| · Analysis | · 需求分析 (包括学习新技术) | 180 | 120 |
| · Design Spec | · 生成设计文档 | 60 | 30 |
| · Design Review | · 设计复审 (和同事审核设计文档) | 30 | 10 |
| · Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | 5 | 5 |
| · Design | · 具体设计 | 20 | 30 |
| · Coding | · 具体编码 | 60 | 40 |
| · Code Review | · 代码复审 | 10 | 10 |
| · Test | · 测试(自我测试,修改代码,提交修改) | 240 | 200 |
| Reporting | 报告 | 110 | 80 |
| · Test Report | · 测试报告 | 60 | 50 |
| · Size Measurement | · 计算工作量 | 20 | 10 |
| · Postmortem & Process Improvement Plan | · 事后总结, 并提出过程改进计划 | 30 | 20 |
| 合计 | 745 | 550 |
首先,看完作业要求之后,心里先有个大概的框架。
再次细看博客之后,发现一些注意点:
这样,大概就有个思路,要去怎么实现。结合上述的注意点,考虑到时间、随机性问题,一开始的直观的想法显然需要改进。
bool Sudoku::judge(int row, int col, int curnum){// check the colrep(i, 0, row)if (sudoku[i][col] == curnum) return false;// check the rowrep(j, 0, col)if (sudoku[row][j] == curnum) return false;// check the areaint belongRow = row / 3 * 3;int belongCol = col / 3 * 3; // get the upleft of the areaint index = (row % 3) * 3 + (col % 3);while (--index >= 0){if (sudoku[belongRow + index / 3][belongCol + index % 3] == curnum) return false;}return true;}
bool Sudoku::dfs(int i, int j){if (i == 9) return true;for (auto &curnum : trynum){if (judge(i, j, curnum)){sudoku[i][j] = curnum;int _i = i;int _j = j;getNext(_i, _j);if (dfs(_i, _j)) return true;sudoku[i][j] = 0;}}return false;}