EE308 Lab 1-2
1. PSP form
| Personal Software Process Stages | Estimated Time/minutes | Completed Time/minutes |
|---|---|---|
| Analysis and Planing | 20 | 25 |
| Program Development | 35 | 35 |
| Program Review | 10 | 15 |
| Performance Test | 10 | 10 |
| Blog Writing | 30 | 35 |
| Github Preparation | 15 | 20 |
| Total | 120 | 140 |
2. Idea to solve the problems
After downloading the problems, I'm trying to understanding what's the main task. It gives me a finished code and requires me to count keyword and analyse the code's structure. This is a simple but cumbersome programming tasks. It needs patience to deal with all the detail point. The toughest part in this task is to spilt the characters in the paragraph.
3. Pseudo code and flow chart
getKeywordNum()
cnt ← 0
for i in code
if substr(code, i, length(keyword)) = keyword then
cnt ← cnt + 1
getSwitchNum()
cntSwitch ← 0
cntCase ← 0
for i in code
if substr(code, i, length('switch')) = switch then
getCaseNum
return cntSwitch, cntCase
getIfElseNum()
cntIfElse ← 0
cntIfElseIfElse ← 0
for i in code
if substr(code, i, length('if')) = if then
if else_if next to if then
cntIfElse ← cntIfElse + 1
else then
cntIfElseIfElse ← CntIfElseIfElse + 1
return cntIfElse, cntIfElseIfElse
main()
input code, level
if level >= 1 then getKeywordNum()
if level >= 2 then getSwitchNum()
if level >= 3 then getIfElseNum() and print cntIfElse
if level >= 4 then getIfElseNum and print cntIfElseIfElse

4. Code description
Get keyword's number
string keyword[] = {"asm", "do","if","return","typedef","autohttps://img-community.csdnimg.cn/images/72dec4246a964445bfd2b3e1b9cefd23.png "#left")
","double","inline","short","typeid","bool","dynamic_cast","int","signed","typename","break","else","long","sizeof","union","case","enum","mutable","static","unsigned","catch","explicit","namespace","static_cast","using","char","export","new","struct","virtual","class","extern","operator","switch","void","const","false","private","template","volatile","const_cast","float","protected","this","wchar_t","continue","for","public","throw","while","default","friend","register","true", "delete","goto","reinterpret_cast","try"};
int cnt = 0;
for (int i = 0; i < 63; i++) {
int len = keyword[i].length();
for (int j = 0; j < input.length(); j++) {
if (input.substr(j, len) == keyword[i]) {
cnt++;
if (input.substr(j, len) == "do") {
if (input.substr(j, 6) == "double") {
cnt--;
}
}
}
}
}
Get switch number
void get_switch(int& st, int id) {
sw.emplace_back(0);
int cnt = 0;
for (int i = st; i < input.length(); i++) {
if (input[i] == '{') {
cnt++;
} else if (input[i] == '}') {
cnt--;
if (!cnt) {
st = i;
return;
}
}
if (input.substr(i, 4) == "case") {
sw[id]++;
}
}
}
Get if else number
void get_if(int& st) {
bool is_else_if = 0;
bool flag = 0;
int cnt = 0;
for (int i = st + 2; i < input.length(); i++) {
if (flag == 1) {
if (input[i] == '{') {
cnt++;
}
if (input[i] == '}') {
cnt--;
if (!cnt) {
st = i + 1;
return;
}
}
}
if (input.substr(i, 2) == "if") {
get_if(i);
}
if (input.substr(i, 7) == "else if") {
if (!is_else_if) {
is_else_if = 1;
cnt_else_if++;
}
i += 7;
} else if (input.substr(i, 4) == "else") {
if (!is_else_if) {
cnt_else++;
}
flag = 1;
i += 4;
}
}
}
5. Unit test




6. Perfomance analyse
We can take advantage of clock() function to analyze the running time.
We can just add 3 lines in the code.
int main() {
string path;
cout << "Please input the file's path: ";
cin >> path;
cout << "Please input completion level: ";
int level;
cin >> level;
double st = clock();
...
double end = clock();
cout << "time cost: " << end - st << endl;
return 0;
}

7. Summarize
In this lab, I've learnt how to commit files and push that to GitHub.
Here is my Github link:https://github.com/DoubleQ666/EE308_Lab1
相关推荐
EE-308 LAB4 final version.7z
这是本次实验的压缩包
研发流程后端开发工具,提示功能开发效率
后端开发工具
Screenshot_2026-11-03-16-23-09-34.jpg
Screenshot_2026-11-03-16-23-09-34.jpg
机器人具有扰动抑制功能的有限时间基于方位角的领航者-跟随者编队控制(Matlab代码实现)
内容概要:本文档标题为《Plecs全桥LLC谐振变换器仿真模型.txt》,但实际内容并未涉及该主题的具体技术细节或仿真建模过程。相反,文档实质是一份由科研服务团队发布的跨学科资源目录,集中展示了大量基于Matlab、Simulink、Python、PSCAD等平台实现的科研项目与算法开发案例,涵盖电力系统、无人机路径规划、微电网优化、状态估计、信号处理、车间调度、图像处理、通信技术、雷达追踪、智能优化算法等多个工程技术领域。每个条目以“【】”标注研究主题,并注明“Matlab代码实现”“Python代码实现”等形式,表明其为可提供技术支持与代码资源的服务项目。文档末尾频繁出现“完整资源下载:公众号——荔枝科研社”及百度网盘链接,明确体现出其作为科研辅助服务推广与引流工具的功能属性。; 适合人群:面向电气工程、自动化、控制科学与工程、计算机科学、智能制造、新能源、航空航天、通信工程及相关交叉学科的研究生、高校教师、科研人员及企业研发工程师。; 使用场景及目标:①为科研人员提供课题选题、技术路线设计与算法实现的参考范例;②辅助学生或研究人员完成课程设计、毕业论文、项目仿真与算法复现任务;③作为第三方技术服务团队的能力展示目录,便于潜在客户快速了解其在多领域提供的定制化仿真与算法开发服务范围。; 阅读建议:此文档并非传统意义上的学术论文或技术教程,而是一份高度碎片化、广告性质浓厚的资源索引清单。读者应忽略其误导性的文件名,将其视为一个综合性科研技术服务目录,重点关注自身研究方向相关的条目,并通过文末提供的公众号或网盘链接进一步获取具体代码与资料。同时,需注意甄别资源的技术质量、原创性与适用性,避免盲目依赖外部服务。
科技中介服务机构如何打造高效、可复制的技术交易服务流程?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。


