双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

EE308Lab1-2

un火 un火 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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 AssignmentSlove the problem of Lab1-2
MU STU ID and FZU STU ID20123311 832002216

github address
https://github.com/HaooLi/EE308-LAB1-2

1.Give the PSP form for this work.

Framework activities:what I didESTIMATE TIME(MINUTE)
PlanUnderstand the meaning of the problem, think of a rough solution process40
designProgram the idea and write a rough outline150
Code ReviewCheck for compliance with programming specifications and check for syntax errors25
TestImport different data for detection20
Postmortem & Process Improvement PlanDo an overall review to make sure the program works10

2.Description of problem-solving ideas. This is the process of how to think and how to find information after getting the title at the beginning.

  1. Find the method to read the c file
  2. Put all keyword lists into string groups
  3. Find out the key words one by one and compare them

3.Design and implementation process. The design includes how the code is organized and the flow chart of the key functions.

  1. Read the file and combine it as a string
  2. Put the keyword table into the array
  3. Match all keywords according to the regular expression and count them
  4. The cases of Switch, case, if-else, and if-elseif-else are solved respectively

img

4.Code description. Show the key code of the project and explain the idea.

  • level 1:
String keywords="abstract、assert、boolean、break、byte、case、"
            + "catch、char、class、continue、default、do、double、else、"
            + "enum、extends、final、finally、float、for、if、implements、"
            + "import、int、interface、instanceof、long、native、new、"
            + "package、private、protected、public、return、short、static、"
            + "strictfp、super、switch、synchronized、this、throw、throws、"
            + "transient、try、void、volatile、while";
String []keyArr=keywords.split("、");

  public static void findKey(String[] keyArr,String c){
      int key_num = 0;
      for(int i = 0; i<keyArr.length; i++) {
          Pattern p=Pattern.compile("[^a-z]"+keyArr[i]+"[^a-z]");
          Matcher matcher=p.matcher(c);
          while(matcher.find()) {
              key_num++;
          }
      }
      System.out.println("key num is "+key_num);
  }

level 2: find the switch and output the number of "case" corresponding to each group

public static void findSwitch(String c){
        //check switch
        Pattern p=Pattern.compile("switch");
        Matcher matcher=p.matcher(c);
        while(matcher.find()) {
            switch_num++;
        }
 
        //find the number of case
        p=Pattern.compile("switch.*?}");
        matcher=p.matcher(c);
        List case_num=new ArrayList();
        while(matcher.find()) {
            String tempText=matcher.toString();//get one switch section
            Pattern temp_p=Pattern.compile("case");
            Matcher temp_matcher=temp_p.matcher(tempText);
            int temp_case_num=0;
            while(temp_matcher.find()) {
                temp_case_num++;
            }
            case_num.add(temp_case_num);
        }
        System.out.println("switch num is "+switch_num);
        System.out.print("case num are ");
        for(int i=0;i<case_num.size();i++) {
            System.out.print(case_num.get(i)+" ");
        }
        System.out.println();
    }

level 3 and 4: find else if and if-else if -else

public static void processElse(String c) {
        Pattern p = Pattern.compile("else\\s*if|else|if");
        Matcher matcher=p.matcher(c);
        Stack<String> s = new Stack();
        while(matcher.find()) {
            String temp=c.substring(matcher.start(),matcher.end());
            s.push(temp);
        }
        Stack<String> res = new Stack<String>();
        boolean flag = false;
        while (!s.isEmpty()) {
            String temp = s.pop();
            if (temp.equals("else")) {
                res.push(temp);
            } else if (temp.equals("else if")) {
                res.push(temp);
 
            } else {
             
                while (res.peek().equals("else if")) {
                    res.pop();
                    // make a little notation that its from else if, not else
                    flag = true;
                }
                if (res.peek().equals("else")) {
                    res.pop();
                }
                //if it's elseif ,add to ifElseIfNum
                if (flag) {
                    ifElseIfNum++;
                    flag = false;
                } else {
                    ifElseNum++;
                }
            }
        }
        System.out.println("if-else num: " + ifElseNum);
        System.out.println("if-elseif-else: " + ifElseIfNum);
    }

5.Unit test screenshots and description.

img

6.Unit test coverage optimization and performance testing, performance optimization screenshots and descriptions.

In the process of adding all the keywords and counting the numbers, I chose to use RE and stack for the statistics. This greatly reduces the amount of code and is easy to understand.

7.Summarize this assignment.

Through this experiment, I understand that if a project wants to be completed quickly and better, first of all we need to make a preliminary plan, and we need to have a full understanding and analysis of the subject. Draw the flowchart of the program to facilitate us to complete the implementation of the code.

...全文

相关推荐

EE-308 LAB4 final version.7z

这是本次实验的压缩包

晨起剪桃花

研发流程后端开发工具,提示功能开发效率

后端开发工具

阳光不锈@

Screenshot_2026-11-03-16-23-09-34.jpg

Screenshot_2026-11-03-16-23-09-34.jpg

2601_97129411

机器人具有扰动抑制功能的有限时间基于方位角的领航者-跟随者编队控制(Matlab代码实现)

内容概要:本文档标题为《Plecs全桥LLC谐振变换器仿真模型.txt》,但实际内容并未涉及该主题的具体技术细节或仿真建模过程。相反,文档实质是一份由科研服务团队发布的跨学科资源目录,集中展示了大量基于Matlab、Simulink、Python、PSCAD等平台实现的科研项目与算法开发案例,涵盖电力系统、无人机路径规划、微电网优化、状态估计、信号处理、车间调度、图像处理、通信技术、雷达追踪、智能优化算法等多个工程技术领域。每个条目以“【】”标注研究主题,并注明“Matlab代码实现”“Python代码实现”等形式,表明其为可提供技术支持与代码资源的服务项目。文档末尾频繁出现“完整资源下载:公众号——荔枝科研社”及百度网盘链接,明确体现出其作为科研辅助服务推广与引流工具的功能属性。; 适合人群:面向电气工程、自动化、控制科学与工程、计算机科学、智能制造、新能源、航空航天、通信工程及相关交叉学科的研究生、高校教师、科研人员及企业研发工程师。; 使用场景及目标:①为科研人员提供课题选题、技术路线设计与算法实现的参考范例;②辅助学生或研究人员完成课程设计、毕业论文、项目仿真与算法复现任务;③作为第三方技术服务团队的能力展示目录,便于潜在客户快速了解其在多领域提供的定制化仿真与算法开发服务范围。; 阅读建议:此文档并非传统意义上的学术论文或技术教程,而是一份高度碎片化、广告性质浓厚的资源索引清单。读者应忽略其误导性的文件名,将其视为一个综合性科研技术服务目录,重点关注自身研究方向相关的条目,并通过文末提供的公众号或网盘链接进一步获取具体代码与资料。同时,需注意甄别资源的技术质量、原创性与适用性,避免盲目依赖外部服务。

荔枝科研社

科技中介服务机构如何打造高效、可复制的技术交易服务流程?.docx

科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。

BIZKEEN
评论
收藏 已收藏
分享
返回顶部
un火
FZU-SE-EE308-2022秋 286 成员 1,014 内容