ee308 lab1_2_832001208_黄子宸

weixin_51478623 2022-10-26 20:40:19
The Link Your Class<https://bbs.csdn.net/forums/MUEE308FZU202201 >
The Link of Requirement of This Assignmenthttps://bbs.csdn.net/topics/608734907
The Aim of This AssignmentSlove the problem lab1_2
MU STU ID and FZU STU ID<20122616_832001208>

1 PSP form

Personal Software Process StagesEstimated Time/minutesCompleted Time/minutes
Planning3030
Estimate2025
Development3030
Analysis9090
Design Spec8080
Design Review3030
Coding Standard3030
Design3030
Coding3030
Code Review Planning4040
Test2025
Reporting3540
Test Report7080
Size Measurement3040
Postmortem&Process Improvement3030
total595630

2 Problem-solving ideas

From all the programming language I have learned , I think the ideal programming language is c++. Because this programming problem is mainly object-oriented, and I have systematically learned it, so I use c++.

3 Design and implementation process

img

4 Code description

#include <stdio.h>
int main(){
int m=1;
double n=0;
long f;
switch(m){
case 0:
break;
case 1:
break;
case 2:
break;
default:
break;
}
switch(m){
case 0:
break;
case 1:
break;
default:
break;
}
if(m<0){
if(m<-1){}
else{}
}
else if(m>0){
if (m>2){}
else if (m==2) {}
else if (m>1) {}
else {}
}
else{
if(n!=0){}
else{}
}
return 0;
}

#include
#include
#include
using namespace std;
string keyword[]={"auto","break","case","char","const","continue","default","do",
"double","else","enum","extern","float","for","goto","if",
"int","long","register","return","short","signed","sizeof","stastic",
"struct","switch","typedef","union","unsigned","void","volatile","while"};

int main(){
int con=0;
string root;
cout<<"the .cpp file name you wanna in the same folder"<<endl;
cin>>root;
cout<<"what level of stastic you want(from 1 to 4)"<<endl;
cin>> con;
ifstream inFile,s1,s2;
inFile.open(root.c_str(),ios::in);
s1.open(root.c_str(),ios::in);
s2.open(root.c_str(),ios::in);
if(!inFile|| !s1 ||!s2){
cout <<"Check the Path of File !" << endl;
exit(0);
}

string str;
int total=32,numt=0; ;
int count[total] = {0};
while (getline (inFile, str)){
for(int m=0;m<total;m++){
int pos;
for(;;){
if(str.find(keyword[m]) != -1){
if(str.find("//") != -1) break;
else{
pos = str.find(keyword[i]);
count[m]++;
str = str.substr(pos + keyword[i].length(),str.length() - pos - keyword[m].length());
}
}
else break;
}
}
}
for(int n=0;n<total;n++){
if(count[n]!=0){
numt+=count[n];
}
}
int num[5]={25,2,6,15,9},hzc[3]={0,0,-1};
int struc[count[num[0]]]={0};
string pick[3]={"else if", "if","else"};
while (getline (s1, str)){
int pos;
for(;;){
if(str.find(keyword[num[1]]) != -1){
if(str.find("//") != -1) break;
else{
struc[hzc[0]]++;
break;
}
}
if(str.find(keyword[num[2]]) != -1){
if(str.find("//") != -1) break;
else{
hzc[0]++;
break;
}
}
if(str.find(pick[0]) != -1){
pos = str.find(pick[0]);
str = str.substr(pos + pick[0].length(),str.length() - pos - pick[0].length());
}
if(str.find(pick[1]) != -1){
if(str.find("//") != -1) break;
else{
hzc[1]++;
break;
}
}
else break;
}
}
int divide[hzc[1]]={0}, ely=0,eln=0;
while (getline (s2, str)){
int pos;
for(;;){
if(str.find(pick[0]) != -1){
if(str.find("//") != -1) break;
else{
divide[hzc[2]]++;
break;
}
}
if(str.find(keyword[num[3]]) != -1){
if(str.find("//") != -1) break;
else{
hzc[2]++;
break;
}
}
else break;
}
}
for(int m=0;m<hzc[1];m++){
if(divide[m]==0){
eln++;
}
else{
ely++;
}
}
for(int o=1; o<con+1; o++){
switch(o){
case 1:
cout<<"total num is: "<<numt<<endl;
for(int j=0;j<total;j++){
if(count[j]!=0){
cout<<keyword[j]<<" num: "<<count[j]<<endl;
}
}
break;
case 2:
if(count[num[0]]!=count[num[2]]){
cout<<" wrong switch structure"<<endl;
}
else{
cout<<"The number of switch structure is:"<<count[num[0]]<<endl;
for(int k=0;k<count[num[0]];k++){
cout<<"switch "<<k+1<<" number of case is: "<<struc[k]<<endl;
}
}
break;
case 3:
cout<<"the number of if-else: "<<eln<<endl;
break;
case 4:
cout<<"the number of if-else if-else: "<<ely<<endl;
break;
default:
cout<<"false"<<endl;
}
}
inFile.close();
s1.close();
s2.close();
return 0;
}

5Test screenshots and description

img

6 summary

This is the first time in my life I've ever used a PSP form. I find that the actual completion time is almost always longer than my estimated time, so I think my ability needs to be improved, which needs training. I use c++ because I have a good command of it. The use of flow chart has given me great benefits, I can clearly understand the before and after and logical relationship between the steps. I searched for a lot of relevant code, which helped me with my programming to some extent, but I still needed to compile and revise the code to achieve the desired effect.

...全文
79 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2023-01-03
  • 打赏
  • 举报
回复

很不错的内容,干货满满,已支持师傅,期望师傅能输出更多干货,并强烈给师傅五星好评

另外,如果可以的话,期待师傅能给正在参加年度博客之星评选的我一个五星好评,您的五星好评都是对我的支持与鼓励(帖子中有大额红包惊喜哟,不要忘记评了五星后领红包哟)
⭐ ⭐ ⭐ ⭐ ⭐ 博主信息⭐ ⭐ ⭐ ⭐ ⭐
博主:橙留香Park
本人原力等级:5
链接直达:https://bbs.csdn.net/topics/611387568
微信直达:Blue_Team_Park
⭐ ⭐ ⭐ ⭐ ⭐ 五星必回!!!⭐ ⭐ ⭐ ⭐ ⭐

点赞五星好评回馈小福利:抽奖赠书 | 总价值200元,书由君自行挑选(从此页面参与抽奖的同学,只需五星好评后,参与抽奖)

285

社区成员

发帖
与我相关
我的任务
社区描述
福州大学 梅努斯国际工程学院 软件工程(2022秋) 教学
软件工程 高校
社区管理员
  • LinQF39
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧