一.GitHub:
GitHub地址
二.PSP表格:
| PSP2.1 | Personal Software Process Stages | 预估耗时(分钟) | 实际耗时(分钟) |
| Planning | 计划 | ||
| · Estimate | · 估计这个任务需要多少时间 | 30 | 30 |
| Development | 开发 | ||
| · Analysis | · 需求分析 (包括学习新技术) | 100 | 120 |
| · Design Spec | · 生成设计文档 | 60 | 60 |
| · Design Review | · 设计复审 | 20 | 30 |
| · Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | 20 | 30 |
| · Design | · 具体设计 | 20 | 30 |
| · Coding | · 具体编码 | 120 | 200 |
| · Code Review | · 代码复审 | 40 | 60 |
| · Test | · 测试(自我测试,修改代码,提交修改) | 40 | 60 |
| Reporting | 报告 | ||
| · Test Repor | · 测试报告 | 20 | 100 |
| · Size Measurement | · 计算工作量 | 30 | 60 |
| · Postmortem & Process Improvement Plan | · 事后总结, 并提出过程改进计划 | 60 | 60 |
| 合计 | 560 | 830 |
三.思路
拿到题目之后其实是懵了挺久,第一个让我头疼的是对文件的操作一无所知,只是隐隐约约记得学c语言的时候有听过,查了百度之后了解到读、写文件使用的ifstream、ofstream操作,类似输入输出流那样对文件进行读写。
对字符的统计以及对行数的统计挺好想的,对于字符的统计用while ((ch=file.get())!=EOF )逐字输入,每次读入计数,循环次数就是总字数,对于具体的要求还需要加入一些判断,对行数的统计,就是逐行读入,每次读完总数加一,具体代码如下:
int CountChar(char *filename)//统计字符数 { int sum = 0; ifstream file; file.open(filename); char ch; while ((ch=file.get())!=EOF ) { sum++; } file.close(); return sum; } int CountLines(char *filename)//统计行数 { ifstream file; file.open(filename); string s; int sum = 0; while (getline(file, s)) { if(s!="