EE308FZ Lab1-2
目录
- 1.PSP form
- 2.Description of problem-solving ideas.
- Level 1
- Level 2
- Level 3and level 4
- 3.Design and implementation process.
- Separate the text from the code
- Level 1
- Level 2
- 4.Code description.
- Level 1
- Level 2
- Level 3
- Level4
- 5.Unit test screenshots and description.
- 6.Unit test coverage optimization and performance testing, performance optimization screenshots and descriptions.
- 7.Summarize
| The Link Your Class | https://bbs.csdn.net/forums/MUEE308FZU202201 |
|---|---|
| The Link of Requirement of This Assignment | https://bbs.csdn.net/topics/608734907 |
| The Aim of This Assignment | do lab1-2 |
| The Aim of This Assignment | <20124546_832001207> |
| github!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | https://github.com/yusdar/114514 |
1.PSP form
| Personal Software Process Stages | Estimated time (minutes) | Real time (minutes) |
|---|---|---|
| Planning | 10 | 10 |
| Estimate | 40 | 50 |
| Development | 10 | 40 |
| Analysis | 10 | 10 |
| Design Spec | 10 | 10 |
| Design Review | 10 | 10 |
| Coding Standard | 10 | 10 |
| Design | 10 | 10 |
| Coding | 60 | 90 |
| Code Review | 10 | 20 |
| Test | 30 | 60 |
| Reporting | 100 | 200 |
| Test Report | 20 | 20 |
| Size Measurement | 10 | 10 |
| Postmortem & Process Improvement Plan | 10 | 10 |
| Total | 350 | 560 |
2.Description of problem-solving ideas.
For the questions raised by the topic, I thought that the language to be used was c++, because this programming language was learned last semester, and it was faster to review.
For a series of requirements required by the topic, I think the first thing to do is to realize the function of reading files. After implementation, it is obvious that there will be a lot of symbols in the code. Before we identify the key words in the code, we must extract the non symbolic part of the code.
Level 1
is obvious. Compare each word extracted from the code with 32 keyword arrays and count them.
Level 2
find switches first, and then calculate the number of cases until the end of traversal or find the next switch. If found, repeat the previous steps.
Level 3and level 4
judge the nesting relationship according to the sequence of code if and else
3.Design and implementation process.
Separate the text from the code

Level 1

Level 2

4.Code description.
Level 1
#include<iostream>
#include<string>
#include<fstream>
#include<vector>
//#include<>
using namespace std;
string Keyword[32]=
{
"auto","break","case","char","const","continue","default","double",
"do","else","enum","extern","float","for","goto","if","int","long",
"register","return","short","signed","sizeof","static","struct",
"switch","typedef","union","unsigned","void","volatile","while"
};
struct KeywordnNum{
string name;
int num;
};
int keywordnum=0;
int main(){
string fileaddress;
string filecontent;
string testcontent;
vector<string> realvocabulary;
cout <<"Enter file address:";
cin >>fileaddress;
ifstream file;
file.open(fileaddress);
while(getline(file,testcontent)){
filecontent+=testcontent;
}
int j=0;
//cout <<filecontent;
for (int i=0;i<filecontent.length();i++){
j=0;
while (filecontent[i+j]<='z' && filecontent[i+j]>='a'){
//cout<<filecontent[i+j]<<endl;
j++;
}
if (j!=0){
realvocabulary.push_back(filecontent.substr(i,j));
//cout<<filecontent.substr(i,j)<<endl;
i+=j;
}
}
for (int i=0;i<realvocabulary.size();i++) {
for (j=0;j<32;j++){
if (realvocabulary[i]==Keyword[j]){
keywordnum++;
break;
}
}
}
cout<<"total num:"<<keywordnum<<endl;
}
Level 2
#include<iostream>
#include<string>
#include<fstream>
#include<vector>
//#include<>
using namespace std;
string Keyword[32]=
{
"auto","break","case","char","const","continue","default","double",
"do","else","enum","extern","float","for","goto","if","int","long",
"register","return","short","signed","sizeof","static","struct",
"switch","typedef","union","unsigned","void","volatile","while"
};
struct KeywordnNum{
string name;
int num;
};
int keywordnum=0;
vector<int> switchcase;
int main(){
string fileaddress;
string filecontent;
string testcontent;
vector<string> realvocabulary;
cout <<"Enter file address:";
cin >>fileaddress;
ifstream file;
file.open(fileaddress);
while(getline(file,testcontent)){
filecontent+=testcontent;
}
int j=0;
//cout <<filecontent;
for (int i=0;i<filecontent.length();i++){
j=0;
while (filecontent[i+j]<='z' && filecontent[i+j]>='a'){
//cout<<filecontent[i+j]<<endl;
j++;
}
if (j!=0){
realvocabulary.push_back(filecontent.substr(i,j));
//cout<<filecontent.substr(i,j)<<endl;
i+=j;
}
}
for (int i=0;i<realvocabulary.size();i++) {
for (j=0;j<32;j++){
if (realvocabulary[i]==Keyword[j]){
keywordnum++;
break;
}
}
if (realvocabulary[i]=="switch"){
switchcase.push_back(0);
}
else if (realvocabulary[i]=="case"){
switchcase[switchcase.size()-1]++;
}
}
cout<<"total num:"<<keywordnum<<endl;
cout<<"switch num:"<<switchcase.size()<<endl;
cout<<"case num:";
for (j=0;j<switchcase.size();j++){
cout<<switchcase[j]<<' ';
}
cout<<endl;
}
Level 3
#include<iostream>
#include<string>
#include<fstream>
#include<vector>
//#include<>
using namespace std;
string Keyword[32]=
{
"auto","break","case","char","const","continue","default","double",
"do","else","enum","extern","float","for","goto","if","int","long",
"register","return","short","signed","sizeof","static","struct",
"switch","typedef","union","unsigned","void","volatile","while"
};
struct ifelse{
bool iselseif =false;
bool iselse=false;
};
int keywordnum=0;
vector<int> switchcase;
int main(){
string fileaddress;
string filecontent;
string testcontent;
vector<string> realvocabulary;
vector<ifelse> fileifelse;
ifelse a;
cout <<"Enter file address:";
cin >>fileaddress;
ifstream file;
file.open(fileaddress);
while(getline(file,testcontent)){
filecontent+=testcontent;
}
int j=0;
//cout <<filecontent;
for (int i=0;i<filecontent.length();i++){
j=0;
while (filecontent[i+j]<='z' && filecontent[i+j]>='a'){
//cout<<filecontent[i+j]<<endl;
j++;
}
if (j!=0){
realvocabulary.push_back(filecontent.substr(i,j));
if (filecontent.substr(i,j)=="if" && filecontent.substr(i-5,7)!="else if"){
fileifelse.push_back(a);
}
else if(filecontent.substr(i,j+3)=="else if"){
//cout <<realvocabulary[i]+realvocabulary[i+1]<<endl;
for (int k=fileifelse.size()-1;k>=0;k--){
if (!fileifelse[k].iselse){
fileifelse[k].iselseif=true;
//cout<<k<<endl;
break;
}
}
}
else if(filecontent.substr(i,j)=="else"){
for (int k=fileifelse.size()-1;k>=0;k--){
if (!fileifelse[k].iselse){
fileifelse[k].iselse=true;
break;
}
}
}
//cout<<filecontent.substr(i,j)<<endl;
i+=j;
}
}
for (int i=0;i<realvocabulary.size();i++) {
for (j=0;j<32;j++){
if (realvocabulary[i]==Keyword[j]){
keywordnum++;
break;
}
}
if (realvocabulary[i]=="switch"){
switchcase.push_back(0);
}
else if (realvocabulary[i]=="case"){
switchcase[switchcase.size()-1]++;
}
}
cout<<"total num:"<<keywordnum<<endl;
cout<<"switch num:"<<switchcase.size()<<endl;
cout<<"case num:";
for (j=0;j<switchcase.size();j++){
cout<<switchcase[j]<<' ';
}
cout<<endl;
cout<<"if-else num:";
int b=0;
for (j=0;j<fileifelse.size();j++){
if (!fileifelse[j].iselseif){
b++;
}
}
cout<<b;
}
Level4
#include<iostream>
#include<string>
#include<fstream>
#include<vector>
//#include<>
using namespace std;
string Keyword[32]=
{
"auto","break","case","char","const","continue","default","double",
"do","else","enum","extern","float","for","goto","if","int","long",
"register","return","short","signed","sizeof","static","struct",
"switch","typedef","union","unsigned","void","volatile","while"
};
struct ifelse{
bool iselseif =false;
bool iselse=false;
};
int keywordnum=0;
vector<int> switchcase;
int main(){
string fileaddress;
string filecontent;
string testcontent;
vector<string> realvocabulary;
vector<ifelse> fileifelse;
ifelse a;
cout <<"Enter file address:";
cin >>fileaddress;
ifstream file;
file.open(fileaddress);
while(getline(file,testcontent)){
filecontent+=testcontent;
}
int j=0;
//cout <<filecontent;
for (int i=0;i<filecontent.length();i++){
j=0;
while (filecontent[i+j]<='z' && filecontent[i+j]>='a'){
//cout<<filecontent[i+j]<<endl;
j++;
}
if (j!=0){
realvocabulary.push_back(filecontent.substr(i,j));
if (filecontent.substr(i,j)=="if" && filecontent.substr(i-5,7)!="else if"){
fileifelse.push_back(a);
}
else if(filecontent.substr(i,j+3)=="else if"){
//cout <<realvocabulary[i]+realvocabulary[i+1]<<endl;
for (int k=fileifelse.size()-1;k>=0;k--){
if (!fileifelse[k].iselse){
fileifelse[k].iselseif=true;
//cout<<k<<endl;
break;
}
}
}
else if(filecontent.substr(i,j)=="else"){
for (int k=fileifelse.size()-1;k>=0;k--){
if (!fileifelse[k].iselse){
fileifelse[k].iselse=true;
break;
}
}
}
//cout<<filecontent.substr(i,j)<<endl;
i+=j;
}
}
for (int i=0;i<realvocabulary.size();i++) {
for (j=0;j<32;j++){
if (realvocabulary[i]==Keyword[j]){
keywordnum++;
break;
}
}
if (realvocabulary[i]=="switch"){
switchcase.push_back(0);
}
else if (realvocabulary[i]=="case"){
switchcase[switchcase.size()-1]++;
}
}
cout<<"total num:"<<keywordnum<<endl;
cout<<"switch num:"<<switchcase.size()<<endl;
cout<<"case num:";
for (j=0;j<switchcase.size();j++){
cout<<switchcase[j]<<' ';
}
cout<<endl;
cout<<"if-else num:";
int b=0;
for (j=0;j<fileifelse.size();j++){
if (!fileifelse[j].iselseif){
b++;
}
}
cout<<b<<endl;
cout<<"if-elseif-else num:"<<fileifelse.size()-b;
}
5.Unit test screenshots and description.




6.Unit test coverage optimization and performance testing, performance optimization screenshots and descriptions.


7.Summarize
I learned a lot from this experiment. For example, I have learned a lot from the analysis and evaluation before the program, how to use csdn to write a blog, and how to iterate versions. Thank you for software engineering! Experience the four points of happiness!
相关推荐
早期颠覆性技术商业化加速:政府主导体系搭建步骤与路径.docx
早期颠覆性技术商业化加速:政府主导体系搭建步骤与路径
科技服务机构促成校企合作时,需遵循哪些规范化操作流程?.docx
科易网基于行业知识库+行业大数据+科技资源要素+AI模型,以AI,赋能技术转移、成果转化、技术经理人培训、知识产权管理、区域产业分析与布局、地方科技招商、创新创业大赛等场景,推出科技创新领域的AI工具、场景化服务和数智化解决方案,推动科技创新与产业创新智能化发展。
美国5435家医院CMS星级质量评级数据集
本数据集基于美国CMS官办的医院质量比较数据库整理加工,覆盖美国56个州和地区的5435家医院,每条记录包含53个字段。数据以医院名录为基础,融合质量评级与衍生分析字段:既有医院名称、地址、所在县州、邮编、电话等基础信息,也包含医院类型、所有制类型、是否提供急诊服务等分类属性,核心是官方发布的总体星级评级与死亡相关指标表现统计(更好、无差异、更差三类计数及脚注),并额外提供所有制分组、急症护理与产科友好标识、评级分档、指标覆盖率、更好更差比率、净指标得分、高评级标记以及各院在本州医院中的占比等衍生字段。其中3166家医院拥有总体评级,4501家提供急诊服务。适用人群:医疗政策研究者、卫生统计分析师、医疗质量管理人员、公共卫生专业师生以及数据科学爱好者。使用场景:适合开展医院质量与所有制关系研究、各州医疗资源与评级分布对比、急诊服务覆盖缺口分析、评级影响因素建模与预测、医院地理分布与可达性研究等课题。其他说明:文件为CSV格式,附带数据字典与说明文档,字段规整、注释完备,可直接导入Python、R、Excel、PowerBI等工具使用,适合课程作业、毕业设计与商业演示,也可作为医疗领域数据仓库建模的入门样例。
战国BC401年世界历史地图矢量文件SHP格式.zip
本资源为《战国BC401年世界历史地图矢量文件SHP格式》压缩包,文件大小约 2.26 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。
路径规划基于遗传算法的3D空间中钻孔规划问题研究(Matlab代码实现)
【路径规划】基于遗传算法的3D空间中钻孔规划问题研究(Matlab代码实现)内容概要:本文研究了在三维空间中利用遗传算法解决钻孔路径规划问题的方法,并提供了基于Matlab的代码实现。文章详细介绍了该问题的背景与意义,指出传统路径规划方法在复杂3D钻孔场景下的局限性,进而提出采用遗传算法进行优化求解。研究涵盖了问题建模、适应度函数设计、遗传操作(选择、交叉、变异)策略以及算法参数设置等内容,通过仿真实验验证了所提方法的有效性和优越性,能够显著减少钻孔路径总长度并提高加工效率。文中还展示了具体的运行结果与对比分析,证明该方法优于传统启发式算法。; 适合人群:具备一定Matlab编程基础和优化算法知识的研究生、科研人员及从事智能制造、数控加工、路径优化等相关领域的工程技术人员。; 使用场景及目标:①应用于复杂零件或多孔板件的数控钻床路径优化,降低加工时间与刀具磨损;②作为智能优化算法的教学案例,帮助理解遗传算法在组合优化问题中的实际应用;③为类似的空间路径规划问题(如机器人钻孔、激光切割等)提供算法参考和技术支持。; 阅读建议:建议读者结合Matlab代码逐段调试运行,深入理解遗传算法在路径规划中的编码方式、适应度计算与迭代优化过程,同时可尝试调整算法参数或引入其他优化策略以进一步提升性能。


