EE308_Lab2

The Link Your Classhttps://bbs.csdn.net/forums/MUEE308FZ
The Link of Requirement of This Assignmenthttps://bbs.csdn.net/topics/600798588
The Aim of This AssignmentExtract keywords of different levels from the C or C++ code files that are read in.
MU STU ID and FZU STU ID19103212 & 831902210

 

PSP form

Personal Software Process StagesEstimated Time(minutes)Completed Time(minutes)
Planning--
Estimate2020
Development--
Analysis6090
Design Spec6090
Design Review3030
Coding Standard3030
Design3030
Coding15001500
Code Review Planning12090
Test6030
Reporting--
Test Report6060
Size Measurement3030
Postmortem&Process Improvement6060
Total20602060

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.

     


In order to meet the needs of the above process, I choose c++ as the programming language for searching and solving because of the compatibility and high efficiency of c++, which I am most familiar with.  

According to the periodic testing requirements, we need to calculate the frequency and scheme structure of specific words, and I think the whole process is to clear the overall goal of the file, then calculate the qualified phrase, and finally get the overall result.  So I'm reviewing C + + about S streams and files;  Search gitub, CNblogs, CSDN.  Then I saw a blog about using substrings and getting a job, which was my main step in processing information.  

 A search function that provides the schema with a specific part of the series and moves that metric to the first character of a qualifying word.  There are two mature and packaged functions  


 3. Design and implementation process 

The program is obtained with command line arguments.  Stream the file from the CPP file and send it to the corresponding string variable.  This is convenient for functions to read and call files.  When function statistics are called, the file stream is directly compared to the string array keyword, the number of words is logged into account, and the total number of words is logged into the number int variable.  

Basic Requirements:

Advanced requirement:

Uplifting requirement & Ultimate requirement:


4.Test samples and results

test example:

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

input data example:

Please enter the path of the file in an absolute path:
D:\CS_java\src\software\test.c
Please enter the select_mod
4

 result:

total num: 35
switch num: 2
case num: 3 2 
if-else num: 2
if -else if- else num: 2

5.Summary

The whole experiment was very challenging and I learned a lot from it.  Although the program can only basically meet the requirements of the laboratory, there are still many deficiencies.  Therefore, there is some room for improvement and development.  I hope I can make progress in 3 months  

My GitHub repository link:https://github.com/cottons12/cottons12

  1. Minimize screenshots and use code blocks
  2. Unit testing and performance improvement should be done better