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

    这是本次实验的压缩包

    晨起剪桃花

    弱电网下光伏并网逆变器序阻抗建模仿真复现扫频法【序阻抗判断稳定性】

    内容概要:本文聚焦于弱电网条件下光伏并网逆变器的序阻抗建模与稳定性分析,系统阐述了基于扫频法的阻抗特性仿真与复现方法。通过构建正负序阻抗模型,深入剖析逆变器在弱电网环境中的动态响应特性,结合锁相环、电流环等关键控制环节对系统阻抗的影响机制,采用序阻抗稳定性判据评估多机并网或复杂电网条件下的系统稳定裕度。研究在Simulink平台中实现激励信号注入、频率响应采集与阻抗曲线绘制,为高比例新能源接入背景下并网系统的稳定性分析提供了可靠的仿真手段与理论支撑,尤其适用于SCI级别论文成果的复现与拓展验证。; 适合人群:电力电子、新能源并网技术及相关领域的硕士/博士研究生、科研人员,以及从事光伏逆变器、微电网稳定控制开发的工程技术人员。; 使用场景及目标:①掌握扫频法在电力电子装置阻抗建模中的具体实施流程;②理解并应用基于序阻抗的稳定性判据进行系统稳定边界分析;③用于高水平学术论文(如SCI期刊)中阻抗建模与稳定性分析部分的仿真复现与方法验证; 阅读建议:建议读者结合文中所述方法与提供的参考文献,自主搭建Simulink仿真模型,逐步完成扰动信号设计、数据采集、傅里叶分析及阻抗拟合全过程,深入探究控制参数变化对系统阻抗特性和稳定性的具体影响,强化理论与实践的融合能力。

    欢多天天写代码

    三相并网逆变器虚拟阻抗+统一有源阻尼策略SVPWM+SPWM调制仿真

    内容概要:本文档系统性地介绍了三相并网逆变器的核心控制技术及其在复杂电网环境下的仿真应用,重点涵盖虚拟阻抗与统一有源阻尼策略在SVPWM和SPWM调制方式下的实现方法,旨在提升逆变器的稳定性与电能质量。内容包括无功功率扰动孤岛检测、中点电位平衡控制、低电压穿越(LVRT)、模型预测控制(MPC)、正负序分离、电网前馈控制等关键技术,并扩展至风储联合调频、微电网下垂控制、虚拟同步发电机(VSG)、构网型逆变器等多种典型电力系统应用场景。所有技术均配有基于Simulink/Matlab平台的完整仿真模型、参考文献及说明文档,强调理论分析与仿真实践的深度融合,突出科研中“借力”与创新思维的重要性。; 适合人群:电气工程、自动化、新能源等相关专业的研究生、科研人员及从事电力电子与可再生能源系统开发的工程师;具备MATLAB/Simulink仿真基础和电力系统专业知识的技术人员。; 使用场景及目标:①开展三相并网逆变器控制策略的研究与优化设计;②复现高水平学术论文中的控制算法;③完成毕业课题、科研项目或工程仿真验证;④掌握虚拟阻抗、有源阻尼、SVPWM/SPWM调制、MPC、VSG等核心技术的建模与实现方法;⑤支撑微电网、构网型变流器等前沿方向的科研攻关。; 阅读建议:建议按照资源目录结构化学习,优先选择与自身研究方向契合的内容模块,结合提供的仿真模型、参考文献和说明材料进行实操演练,注重从理论推导到仿真实现的全过程理解,充分利用共享网盘资源深化技术掌握,提升科研效率与创新能力。

    欢多天天写代码

    chromedriver-win32-159.0.8133.0(Canary).zip

    chromedriver-win32-159.0.8133.0(Canary).zip

    LCG元

    计算机“101计划”《人工智能引论》教学大纲+课件+实训案例

    计算机“101计划”《人工智能引论》教学大纲+课件+实训案例

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