EE308FZ LAB_1_2

Posted 小火柴x_x

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EE308FZ LAB_1_2相关的知识,希望对你有一定的参考价值。

EE308FZ_Lab_2

1.Basic Information

The Link Your Classhttps://bbs.csdn.net/forums/MUEE308FZU202201
The Link of Requirement of This Assignmenthttps://bbs.csdn.net/topics/608734907
The Aim of This Assignment concrete contentKeywords and function matching
MU STU ID and FZU STU ID20123337_832002126

Github Link:   https://github.com/LittleMatcher/EE308FZ_LAB

Specificatione.g.
Variable namingint price_count_reader;
Maximum number of characters per line80
Maximum number of function lines50
Function and class namingAddTableEntry() File
constantconst int kDaysInAWeek = 7;
Blank line ruleBetween the functions
Annotation rules//
Space before and after operatorYes

2.PSP

Personal Software Process Stageswhat should I dotime(min)
PlanningUnderstand the purpose of the experiment and plan the time10
AnalysisDraw the basic framework of the project10
Design ReviewWrite the key function70
DevelopmentReduced memory footprint and time optimization20
PostmortemFinish the report50

3.Problem-solving ideas

    As can be seen from the title, this experimental project involves text matching, so we can preliminarily decide to use Regular Expressions. After analyzing the test files given in the document, keyword matching can be performed through traversal. Since all related functions of if end with else, we can think of stack – first in, last out; switch has no good idea, the preliminary consideration is also to use the stack.

4.Design and implementation process

  1)Code framework

  2)Flow chart

   ( a )void countKey(String str)

   ( b )void countFunSwitch(stack switchCase)

   ( c )void countFunIf(stack str_stack)

   

5.Code

  1)Read files with functions used

  Push the string onto the stack.
  Converts each line in the file to a string.
  To avoid confusion between switch and if, two stacks were created to store the two functions separately

void File::LodeFile(const string& path)

    FILE* p = fopen(path.c_str(), "rb");
    if (!p)
        exit(0);
    char str[N + 1];
    strcpy_s(str, path.c_str());
    stack <string> str_stack; //Create a stack
    stack <string> switchCase;
    while (fgets(str, N, p) != NULL)
    
        //printf("%s", str);
        //cout << str ;
        countKey(str);
        if (isEI(str)) 
           // cout << "ELSE IF" << endl;
            str_stack.push("else if");
        
        else if (isElse(str)) 
           // cout << "ELSE" << endl;
            str_stack.push("else");
            countFunIf(str_stack);
        
        else if (isIf(str)) 
           // cout << "IF" << endl;
            str_stack.push("if");
        
        else if (isSwitch(str)) 
            //cout << "SWITCH" << endl;
            switchCase.push("switch");
        
        else if (isCase(str)) 
           // cout << "CASE" << endl;
            switchCase.push("case");
        
        else 
        
    
    countFunSwitch(switchCase);
    fclose(p);


  2)Keywords Counting

  This paragraph uses the simplest method - exhaustive. Store all the keywords in an array of strings and iterate through them to match the strings passed in.

void countKey(string s) 

    string keyword[32] =  "auto", "break", "case", "char", "const", "continue", "default", "do", "double", "else", "enum", "extern",
                "float", "for", "goto", "if", "int", "long", "register", "return", "short", "signed", "sizeof", "static",
                "struct", "switch", "typedef", "unsigned", "union", "void", "volatile", "while" ;
    s = "   " + s;
    for (int i = 0; i < 32; i++) 
        regex pattern("[^a-zA-Z0-9_]" + keyword[i] + "[^a-zA-Z0-9_]");
        smatch result;
        bool ismatch = regex_search(s, result, pattern);
        if (ismatch) 
            countKeyNum++;
            //cout << keyword[i] << endl;
        
    

  3)Switch and case Counting

  This function runs after a loop that reads the file. If the file contains the switch function, all keywords have been pushed on the stack.Build an array to store the number of cases,index is the number of switch, when pop to “case”, then caseNum[switchNum]++; When pop to switch, SwitchNum+ +.

void countFunSwitch(stack <string> switchCase) 
    while (!switchCase.empty()) 
        while (switchCase.top() == "case") 
            caseNum[switchNum]++;
            switchCase.pop();
        
        if (switchCase.top() == "switch") 
            switchNum++;
            switchCase.pop();
        
    
 

  4)If Counting

  Notice that all if-related functions start with if and end with else. When an “else” appears in the stack, pop can be started up to the nearest “if” . if “elseif” appears in the middle, ifelseif_num++; If not, ifelse_num++;

void countFunIf(stack <string> str_stack) 
    int count = 0;
    while (!str_stack.empty()&&str_stack.top() != "if") 
        if (str_stack.top() == "else if")          
            count++;
        
        
        str_stack.pop();
       
    
    if (count == 0) 
        ifelse_num++;
    
    else 
        ifelseif_num++;
    
    if(!str_stack.empty()) 
        str_stack.pop();
    
    


6.Unit test screenshots and description



7.Optimize

 There is too little code to have a significant impact on performance, so there is no optimization.

8.Summary

  I feel that the overall idea is correct and meets the experimental requirements. I haven’t written code for too long. I can’t realize the code quickly after I have ideas. Test case coverage may not be comprehensive, and you don’t know what bugs will occur.

Lab_7_Automating_v2.5

System Operations - Lab 7: Automating Deployments with CloudFormation - 2.5
==================================================================================================================

Using this command reference.

==================================================================================================================

1. Locate the section you need. Each section in this file matches a section in the lab instructions.


2. Replace items in angle brackets - < > - with appropriate values. For example, in this command you would replace the value - <JobFlowID> - (including the brackets) with the parameter indicated in the lab instructions:

   elastic-mapreduce --list <JobFlowID>.

   You can also use find and replace to change bracketed parameters in bulk.

3. Do NOT enable the Word Wrap feature in Windows Notepad or the text editor you use to view this file.


++++1. Change and Run the AWS CloudFormation Template ++++

==================================================================================================================
1.1 Add AMI ID Lookup to Template
==================================================================================================================
1.1.1 https://d2lrzjb0vjvpn5.cloudfront.net/sys-ops/v2.5/lab-7-automating/static/Lab-7-Start-CF.template

1.1.4 Copy the new ImageId property code from the command reference file

        {
          "Fn::FindInMap" : [
            "AmazonLinuxAMI", {
              "Ref" : "AWS::Region"
            },
            "AMI"
          ]
        }

==================================================================================================================
1.2 Run the Template
==================================================================================================================
1.2.7 https://d2lrzjb0vjvpn5.cloudfront.net/sys-ops/v2.5/lab-7-automating/static/Lab-7-Completed-CF.template		

		
++++2. Update Stack with New Template ++++

==================================================================================================================
2.1 Add InstanceType Parameter to Template
==================================================================================================================

2.1.1 Copy the BastionInstanceType parameter

,
		"BastionInstanceType" : {
			"Type" : "String",
			"Description" : "The size of the instance to use for the bastion host."
		}

2.1.4		Copy the Ref parameter

{
	"Ref" : "BastionInstanceType"
}

++++3. Challenge Solution: Debugging a CloudFormation Template++++

==================================================================================================================
3 Challenge Overview
==================================================================================================================

URL to download the debug template

https://us-west-2-aws-training.s3.amazonaws.com/awsu-ilt/sys-ops/v2.5/lab-7-automating/static/CFDebug.template


==================================================================================================================
3.2 Fixing the Resource Error
==================================================================================================================

3.2.4 Replace the ImageId parameter

		"ImageId" : {
      "Fn::FindInMap" : [
        "AmazonLinuxAMI", {
          "Ref" : "AWS::Region"
        },
        "AMI"
      ]
    }


© 2016 Amazon Web Services, Inc. or its affiliates. All rights reserved.

以上是关于EE308FZ LAB_1_2的主要内容,如果未能解决你的问题,请参考以下文章

ESP8266 + oled I2C屏幕动态雪花效果显示实例程序

Lab_1_SysOps_Compute_Linux_v2.5

Lab_1:练习2——使用qemu执行并调试lab1中的软件

HCIE实验LAB_1

软件测试_lab2_Selenium自动化

在 ionic 2.1.8 中无法获取 //__ion-dev-server/ionic_lab.html