EE308LAB1.2

XIiww XIiww 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
The Link Your Class

https://bbs.csdn.net/forums/MUEE308FZU202201

The Link of Requirement of This Assignmenthttps://bbs.csdn.net/topics/608734907
The Aim of This AssignmenExtract keywords of different levels from the C or C++ code files that are read in.
MU STU ID and FZU STU ID20122217_832001320

GitHub Repository: git@github.com:xiwwww/EE308FZ.git

 

 

目录

1.PSP Form

2.Program Requirements

3.Code Description:

4.Summary

 

1.PSP Form

 

 

Personal Software Process Stages

Estimated time(min)

Time(min)

Planning

15

15

Estimate

20

30

Analysis

120

150

Design Spec

30

45

Design Review

30

45

Coding Standard

20

30

Design

60

90

Coding

400

500

Test

30

60

Reporting

45

60

Size Measurement

30

30

Postmortem&Process Improvement

40

50

total

810

1105

 

 

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

 

3.Code Description:

 for basic level 1

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using std::string;

void Count_Keywork_Switch_Case(string inputfile,int level) {//TODO(JZ)
    std::ifstream inFile(inputfile, std::ios::in); //open file
    string x;
	string y;
	int Keyword_num = 0;
    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","union","unsigned","void","volatile","while"};
	for (int i = 0;i < x.length(); i++) {
			if (x[i] >= 'A' && x[i] <= 'z')
			{
				y += x[i];
			}
		}
			
		for (int a = 0; a < 32; a++) {
			if (keyword[a] == y) {
					
				Keyword_num += 1;
			}
		}
		}

Level 2: output the number of "switch case" structures, and output the number of "case" corresponding to each group.

if (y == "switch") {
			Count += 1;
			Switch_Loop += 1;
		}
		
		if (Switch_Loop > 0 && y == "case") {
			Case_Number += 1;
		}
		
		if (Switch_Loop > 0 && y == "default") {
			Case_Num += std::to_string(Case_Number);
			Case_Number = 0;
			Switch_Loop = 0;
		}

for level 3 and 4,output the number of "if else" structures and the number of "if, else if, else" structures. Before completing the more difficult requirements, you need to complete the Lower requirements. 

here is brief struc of my code, detail will be show in Github.result:

void Count_If_Elseif(string inputfile, int level) {
    while (getline(inFile, x)) {
 
		for (int i = 0; i < x.length(); i++) {
			if (x[i] >= 'A' && x[i] <= 'z')
			{
				if (x[i] == 'e' || x[i] == 'f' || x[i] == 'l' || x[i] == 's' || x[i] == 'i')
				{
					z += x[i];
				}
			}
 
		}
		
		if (z.length() >= 2 && z.substr(0, 2) == "if") {
			line.push_back(z.substr(0, 2));
 
		}
		
		if (z.length() >= 2 && z.length() <= 6 && z.substr(0, 4) == "else") {
			line.push_back(z.substr(0, 4));
 
		}
		
		if (z.length() >= 6 && z.substr(0, 6) == "elseif") {
			line.push_back(z.substr(0, 6));
 
		}
 
		z = "";
	}
	inFile.close();
 
    for (int a = 0; a < line.size(); a++) {//if else elseif 
		if (line[a] == "if") {
			Sec_else += 1;
			Sec_elseif += 1;
 
		}
		
		if (line[a] == "else" && Sec_else > 0) {
			Count_Ifelse += 1;
			Sec_else -= 1;
			Sec_elseif -= 1;
		}
		
		if (line[a] == "elseif" && Sec_elseif > 0) {
			Sec_else -= 1;
			Sec_elseif -= 1;
			Count_Elseif += 1;
		}
 
 
	}

result: 

total num: 35

switch num: 2

case num: 3 2

if-else num: 2

if -else if- else num: 2

 

4.Summary:

I think this assignment has gone through a lot of hardships. At the beginning, I was very confused when I saw the topic and didn't know how to start, so I consulted my classmates and inquired a lot of information. After writing the code, I kept debugging. Through this experiment, I have deepened my understanding of Python. At the same time, I have realized that my code ability is relatively weak and I need to keep practicing. I hope the next experiment will not be so hasty and confused.

    ...全文

    相关推荐

    EE-308 LAB4 final version.7z

    这是本次实验的压缩包

    晨起剪桃花

    Kubernetes集群部署与管理实战项目

    Kubernetes集群部署与管理实战项目

    miaobinfei

    三相PWM整流器双闭环控制仿真模型(Simulink仿真实现)

    内容概要:本文详细介绍了三相PWM整流器双闭环控制的Simulink仿真模型,重点围绕电压外环和电流内环的协同控制策略展开。通过建立系统的数学模型与控制框图,实现了对整流器输出直流电压的高精度稳定控制以及输入电流的单位功率因数校正。内容涵盖系统建模、控制器参数设计、PWM调制方式的选择与实现、坐标变换(如abc/dq变换)的应用,以及仿真结果的全面分析。通过动态响应测试、抗干扰能力验证和稳态性能评估,充分展示了双闭环控制在提升系统稳定性、响应速度和电能质量方面的优越性,为电力电子装置中高性能整流技术的研究与工程应用提供了完整的仿真验证方案。; 适合人群:具备电力电子技术、自动控制理论及Simulink仿真基础,从事新能源发电、电力传动、工业自动化等相关领域研究的研发人员及高校研究生。; 使用场景及目标:①掌握三相PWM整流器的工作原理及其双闭环控制结构的设计方法;②深入理解电压外环与电流内环的耦合关系与解耦控制策略;③学习基于Simulink的电力电子系统建模、仿真与性能分析流程;④为实际工程项目中的整流器控制系统开发提供理论支持与实践参考。; 阅读建议:建议读者结合电力电子教材与控制理论知识同步学习,重点关注控制器参数整定过程与仿真结果的物理意义解读,并动手复现仿真模型以加深对控制逻辑的理解。

    大龙不吃小鱼干

    47-基于STM32的自动衣物晾晒控制系统设计(设计+原理+程序+仿真+全套资料).rar

    项目47-基于STM32自动衣物晾晒控制系统设计 资料包括Proteus仿真+Keil程序+Altium Designer原理图+软件安装包+参考设计说明书+答辩PPT+设计流程图,保证资料完整性! 功能: (1)本设计以STM32单片机为控制核心,精准调控自动衣物晾晒控制系统,实现智能化运行与高效管理。 (2)采用DHT11温湿度传感器,实时精准感知环境温湿度,为衣物晾晒提供科学的环境数据参考。 (3)人体红外模拟开关用于检测人体活动,实现有人时系统特定操作,无人时智能调整晾晒模式,便捷实用。 (4)OLED12864显示屏清晰呈现信息,包括温湿度、系统状态等,方便用户直观了解衣物晾晒情况。 (5)步进电机作为执行装置,精准控制衣物晾晒角度,确保衣物均匀受光,提升晾晒效果,资料可借鉴。

    创界工坊工作室

    MediaPipe跌倒检测看护系统实战

    这是一套基于 MediaPipe Pose 的老人跌倒检测看护系统完整实战教程,给普通摄像头装上一双看得懂人体姿态的眼睛,逐帧提取 33 个人体关键点,用躯干倾角和肩膀高度骤降两路几何特征判断人有没有倒下,判定成立就地报警并自动留档。交付物含可运行 Python 源码、演示视频、9 章文档(三件套)、PPT 和 6 张真跑截图。 内容围绕 main.py 的命令:gui 打开 Tkinter 双栏看护面板,左栏实时画面加骨架叠加与状态条,右栏事件列表,跌倒即弹窗,倾角阈值、骤降阈值、连续确认帧数三根滑杆当场可调;video 不开界面跑完整段视频,产出骨架序列帧与事件 CSV;demo 程序化生成演示视频,没有摄像头也能复现整条链路。报警瞬间追加一行 CSV 并保存现场截图,CSV 用 utf-8-sig 编码,Excel 双击打开中文不乱码。 亮点在于无显卡要求:普通 CPU 即可运行,实时 30-40 FPS,无需训练;依赖锁定 Python 3.10 + mediapipe 0.10.9 + opencv-python 4.8.1.78 + numpy 1.26.0 + pillow 12.3.0;第 7 章整理 13 个以上高频报错;第 8 章给出换多人姿态、接入摄像头、对接云平台的二次开发路径。 适合做计算机视觉方向毕业设计的学生、智慧养老课题的学习者,以及需要课程大作业演示项目的开发者。会 Python 基础即可,无需深度学习背景。 使用方式:进入 src 目录建虚拟环境并 pip install -r requirements.txt,py main.py demo 生成演示视频,py main.py 启动看护面板选演示视频点启动即可看到跌倒报警全流程。

    小鹿( ﹡ˆoˆ﹡ )
    评论
    收藏 已收藏
    分享
    返回顶部
    XIiww
    FZU-SE-EE308-2022秋 286 成员 1,014 内容