weixin_45930152 2021-09-23 12:39 采纳率: 0%
浏览 15

EE308 lab2

 

The Link Your Classhttps://bbs.csdn.net/forums/MUEE308FZ?category=0
The Link of Requirement of This Assignmenthttps://bbs.csdn.net/topics/600798588
The Aim of This AssignmentCode personally & learn git and github & learn the process of writing a project & learn unit test and performance test
MU STU ID and FZU STU ID19105886       &831902204

    My Github Library

 The code has been uploaded

 https://github.com/zxc123asd456/nova

 

PSP FROM

Personal Software Process StagesEstimated Time (minutes)Actual Time (minutes)
Planning2015
Estimate2020
Development00
Analysis240360
Design Spec00
Design Review00
Coding Standard3030
Design6050
Coding120150
Code Review6060
Test6060
Test Report00
Size Measurement2015
Postmortem & Process Improvement Plan2020
Total650780

Idea of solving problem

1. Decomposing tasks: When I first saw this problem, I scanned the requirements of the problem and found out the points that I had difficulty in, first, how to import the.c file, which form should be used for matching, and second, the definition of "keyword" and the judgment of different structures. Determined the difficulty, I probably want to convert the file into a string form for matching, so I first study the body of the code - the "keyword" part:

2. As for the keyword search part of the problem content, the first thing that came to my mind was the string matching problem I had learned in C language before. I went through the process to find the corresponding keyword and recorded it. So I think of all the key words to build a table to record, based on my choice of programming language is c + +, c + + object-oriented programming reminds me of the nature of class to create a program, to record the program object to establish an array of objects, the nature of the definition of each object are keywords and occurrences, keyword is encountered in traversed number plus one of the key words. But when I ran into trouble, it is how to keywords and application of a number of matches, check a lot of information here, spent a lot of time, later in the discussion with your classmates, I learned the find () function, can be directly through the find function to find the current string, if has the return key word in the correct value, Can solve the problem of both match each other, the next question is how to convert (.) c program into a string, as we can match the pattern, at first I think is will. C file save as. TXT file to read, to open the file on the network of function is complicated, at first I choose the fopen () function, I didn't find any strings, so I just opened the file. Then I went to in (), opened the.txt file successfully, and read the file line by line using getLine (). Having solved the input problem, I could write the function and test it.

 

Design implementation process

First we read the file, it is easy so let's just do it in the main method.

string file_name;
    /* input file address*/
    cout << "Please enter the file address:" << endl;
    cin >> file_name;
    ifstream in(file_name.c_str());//read the file (example:./test.c)./
    string str;
    if (in.is_open())
    {
        while (!in.eof())//file -> str
        {
            getline(in, str); //search by lines
            Search_name(str);
            Ifelse_judge();
        }
    }
    else
    {
        cout << "Error opening " << file_name << " for input" << endl;
        return -1;
    }

Second Keyword record
Because only keywords and {} symbols are needed, only these are recorded. If the character is a letter, continue reading until it is a space, and then compare it with the keyword table. If it is one of the characters, note it down.

public:
    string name;//Keyword
    int number; //Keywords' numbers
    void Search_name(string);//the function of searching keywords
    void Print_number();
    void Switch_search(int);
    void Case_count(int);
    void Ifelse_search(int);
    void Ifelse_judge();
};
/*Define the keyword array*/
program keyword[32] = 
    { "auto", 0,"break",0,"case",0,"char",0,"const", 0,"continue",0,"default",0,"do", 0,     
       "double",0,"else",0,"enum",0,"float",0,"for",0,"goto",0,"if",0,"int",0,
       "long",0,"register",0, "while",      
       0,"reuturn",0,"short",0,"signed",0,"sizeof",0,"static", 0,
       "struct",0,"switch",0,"typedef",0,"union",0,"unsigned",0,"void", 0 , 
       "volatile",0,"while", 0 };
/*declare variables and functions*/
/*advanced requirements*/
int switch_number = 0;
int case_number[50] = {0};
/*further requirements*/
int ifelse_number = 0;
bool If_flg = false, Else_flg = false;
int Stack[101] = {0}; //define ifelse's stack
int top = 0; //stack's top
int flg = 0;//"else if"'s flag
/*final requirements*/
int ifelseifelse_number = 0;

The test results

 The performance test

Summary


On the whole, I personally think this assignment helped me a lot.

1. This programming assignment clearly exposed my lack of programming ability caused by lack of practice at ordinary times, and I often felt difficult in the process of writing codes. Some problems could not be well realized even if I had certain ideas, which reminded me that the training of code ability should be emphasized at ordinary times.

2. Let me see the gap between myself and other students. When writing blogs, many students have finished their homework.

3. Exercise my ability of self-study, most have taught course code, before the work is the need to find information and contact the learned knowledge to complete, for all kinds of coding methods and new functions of learning, to learn, through the network to achieve different functions, I also find a lot of English websites, The ability to retrieve and query data has been improved.

4. I learned to test and improve the code performance after coding, which I had never used before. The test of the code was also an indispensable part of the whole process, which enabled me to have a deeper understanding of coding and project implementation.

5. Learned the basic usage of GitHub and some Git commands, committed my own code constantly, learned the basic operations of programmers, and had a better understanding and mastery of open-source coding methods in the future.

I see a long way to go. I hope I can do better and better in the following assignments and constantly improve my ability.

  • 写回答

1条回答 默认 最新

  • 资料小助手 2023-02-02 11:33
    关注

    mark

    评论

报告相同问题?

问题事件

  • 创建了问题 9月23日

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型