EE308 LAB2

831902121南 2021-09-26 21:41:08

 

The Link Your Classhttps://bbs.csdn.net/forums/MUEE308FZ
The Link of Requirement of This Assignmenthttps://bbs.csdn.net/topics/60079858L8
The Aim of This Assignment<learn git and github>
MU STU ID and FZU STU ID<19103468_831902121>

Catalogue

 

1.PSP Form

2.Program requirements

3.Description of problem-solving ideas

4.Design and implementation process

5.Code description

6.Unit teat screenshots and description

7.Summary

 

 

1.PSP Form

Personal Software Process StagesEstimated time(min)Time(min)
Planning6060
Estimate1010
Development3030
Analysis180300
Design Spec----
Design Review1030
Coding Standard1020
Design120120
Coding180240
Code Review6060
Test3030
Reporting6060
Test Report9090
Size Measurement3040
Postmortem&Process Improvement3050
total9601200

2.Program requirements

1. Basic requirement: output "keyword" statistics

2. Advanced requirement: output the number of "switch case" structures, and output the number of "case" corresponding to each group

3. Uplifting requirement: output the number of "if else" structures

4. Ultimate requirement: output the number of "if, else if, else" structures

Before completing the more difficult requirements, you need to complete the Lower requirements.

 

3.Description of problem-solving ideas

 I'm sorry that this experiment  I can only make basic requirement and advanced requirement with my ability. 

The programming language I choose is C language.

Before writing this code, I first learned the file operation part of C language by myself, and learned how to read the C language program in the form  of string from txt file format. Then, I think it is the easiest to use structural array to detect keywords in C program.First, we extract two parameters entered by the  user, one of which is the file location, so that we can open the file. Be careful! Here we only need to read this function, so we choose "r", then we define a new string--ch, and then we can store the C program in ch as a string. Next, we can start searching for this string. (More detailed ideas are shown in the fifth part, code description).


4.Design and implementation process

 

5.Code description

Above all , we get two parameters entered by the  user, one of which is the file location, so that we can open the file. And then we fetch the txt file in the form of char:

we can definite a structure as below:

 

As mentioned above, my plan is that half of this structure is the c keyword we want to find, and the other part is the number of times we find this keywords, and then we make a structure array as below:


Then we use the Strcmp function to detect the keywords in the string. Once the same keyword is detected, the number after it will be added by one

if the same string is detected, Strcmp function will return 0.

the code as below:

After that, we add the whole value of arr[i].count, the value of total_number is the sum of c keywords.

Next, We should check the number of cases. Before that, let's create an array that large enough.
Our method is to set a variable case_ number (its initial value is zero). When case is detected, it will add one. When switch is detected, it will immediately store its current value in an array, and then it will change to the initial value of 0. Then we can output the numbers in the array in turn to meet the advanced requirements. However, it should be noted that the first number in the obtained array must be zero, and we are the best skip the first digit of the array when outputting the answers.
 

 

6.Unit teat screenshots and description

The C language program used to test is the sample program provided by Lab3.

The following figure shows the output of the program test:

  In this way, it is not difficult to find that the test results have achieved our expected purpose.

7.Summary   

 In this experiment, I failed to complete the following two requirement -Uplifting requirement and Ultimate requirement , therefore I can't complete the whole lab3 here. In the future study, I will continue to motivate myself and strive to upgrade the code of this experiment after mastering more knowledge so that this program can complete more functions.
 

 

 

 

 

...全文
593 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

183

社区成员

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

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