软件工程第二次作业

第二次作业

git地址https://github.com/Princess-Violet/Calculator-of-Mine
git用户名PrincessViolet
学号后五位:61209;
博客地址https://www.cnblogs.com/PrincessViolet/
作业链接https://edu.cnblogs.com/campus/xnsy/Autumn2019SoftwareEngineeringFoundation/homework/7590

环境配置

我使用的是编译器VS2019社区版。不知道是不是下载服务器不在国内的原因,下载速度感人~~steam在成都都有下载节点能满速下载~~,挂了美国节点VPN后速度有了明显提升。
![](https://img2018.cnblogs.com/blog/1784272/201909/1784272-20190921190254902-1770717170.png)

代码设计思路

我在生成试题上为了简化代码,只设定了7种混合运算情况,通过生成随机数来决定,计算数字也是由随机数生成。
#include<iostream>
#include<time.h>
#include<stdlib.h>

using namespace std;

int random(){return rand()%99 +1; }

void generate() 
{
	int one = random(), two = random(), three = random(), four = random();
	int check;
	int ret = rand() % 7;
	switch (ret)
	{case 0:
		cout << one << "*" << two << "+" << three << "=" << endl;
		check = one * two + three;
		break;

	case 1:
		cout << one << "-" << two << "*" << three << "=" << endl;
		check = one - two * three;
		break;

	case 2:
		while (two) { two = random(); }
		cout << one << "/" << two << "+" << three << "=" << endl;
		check = one / two + three;
		break;

	case 3:
		while (three) { three = random(); }
		cout << one << "*" << two << "/" << three << "=" << endl;
		check = one * two / three;
		break;


	case 4:
		while (two) { two = random(); }
		while (three) { three = random(); }
		cout << one << "/" << two << "/" << three << "=" << endl;
		check = one / two / three;
		break;

	case 5:
		cout << one << "*" << two << "*" << three << "=" << endl;
		check = one * two * three;
		break;

	case 6:
		while (three) { three = random(); }
		cout << one << "-" << two << "/" << three << "=" << endl;
		check = one - two / three;
		break;

	default:
		cout << "程序错误请重启!" << endl;
		break;
	}
}

int main()
{
	int test_num;
	cout << "请输入要生成的试题个数:";
	fflush(stdin);
	cin >> test_num;
	fflush(stdin);
	for (int i = 1; i <= test_num; i++)
	{
		srand(rand());
		generate();
	}
	return 0;
}

运行结果:

github代码克隆与提交

克隆项目的时候,我并没有使用教程的git命令行软件,而是找到了GitHub桌面版,感觉用这个更加方便,而且在把Java转换为C艹的时候更简单。

我按照教程git add和git commit各种报错,搞的我心态崩溃,本来全英语界面就很不友好,各种英语专业术语就算英语6级过了也未必体验良好。最后我选择了借助浏览器翻译功能手动上传。

总结

这次作业最大的收获就是学会了github的使用和了解了单元测试与效能工具。但说实话我这次学会的只是冰山一角,软件工程开发的路上我还有很多要学的。至于GitHub的使用体验是真的糟糕,倒是VS2019相比以前的VC6++和code:block要好得多,功能齐全而且更加人性化。
posted @ 2019-09-21 19:22  PrinzViolet  阅读(134)  评论(1编辑  收藏  举报