183
社区成员
The Link Your Class | https://bbs.csdn.net/forums/MUEE308FZ |
---|---|
The Link of Requirement of This Assignment | https://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 Stages | Estimated time(min) | Time(min) |
---|---|---|
Planning | 60 | 60 |
Estimate | 10 | 10 |
Development | 30 | 30 |
Analysis | 180 | 300 |
Design Spec | -- | -- |
Design Review | 10 | 30 |
Coding Standard | 10 | 20 |
Design | 120 | 120 |
Coding | 180 | 240 |
Code Review | 60 | 60 |
Test | 30 | 30 |
Reporting | 60 | 60 |
Test Report | 90 | 90 |
Size Measurement | 30 | 40 |
Postmortem&Process Improvement | 30 | 50 |
total | 960 | 1200 |
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.