[关闭]
@M1saki 2017-09-07T18:57:42.000000Z 字数 2335 阅读 873

软工实践_Task2

软工实践


相关要求第二次作业——个人项目实战
github传送门


PSP表格:

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

解题思路


设计实现


代码说明

  1. bool Sudoku::judge(int row, int col, int curnum)
  2. {
  3. // check the col
  4. rep(i, 0, row)
  5. if (sudoku[i][col] == curnum) return false;
  6. // check the row
  7. rep(j, 0, col)
  8. if (sudoku[row][j] == curnum) return false;
  9. // check the area
  10. int belongRow = row / 3 * 3;
  11. int belongCol = col / 3 * 3; // get the upleft of the area
  12. int index = (row % 3) * 3 + (col % 3);
  13. while (--index >= 0)
  14. {
  15. if (sudoku[belongRow + index / 3][belongCol + index % 3] == curnum) return false;
  16. }
  17. return true;
  18. }
  1. bool Sudoku::dfs(int i, int j)
  2. {
  3. if (i == 9) return true;
  4. for (auto &curnum : trynum)
  5. {
  6. if (judge(i, j, curnum))
  7. {
  8. sudoku[i][j] = curnum;
  9. int _i = i;
  10. int _j = j;
  11. getNext(_i, _j);
  12. if (dfs(_i, _j)) return true;
  13. sudoku[i][j] = 0;
  14. }
  15. }
  16. return false;
  17. }

测试运行

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注