## 第二次软件工程基础作业

GIT地址：https://github.com/genmone/-

GIT用户名：genmone

配置过程主要的问题是微软的官网不存在2017community版本的下载，为了能够解决配置问题，我在网上查阅2017与2019的环境配置的不同在仔细对照。使得下载的2019vs与2017版本的功能与环境保持相似性。以此来达到相同的配置要求。

对于git我选择了桌面版方便与使用与代码克隆。

再循环结构中用随机函数，产生四个符合范围的整数，再通过内嵌的循环结构产生相应的算数运算符，最后用·条件选择来得到适合的结果。以此来得到算术运算式。

#include <iostream>

using namespace std;

int main()
{
float number[3],result;
int time,time_1,total;
char way[2];
cout << "输入产生四则运算式的个数" << endl;
cin >> time;
for (total=1;total<=time; )
{
result = 0;
number[0] = rand()%100;
number[1] = rand()%100;
number[2]= rand()%100;
for (time_1=0;time_1<2;time_1++)
{
int way_1;
way_1 = rand() % 4 + 1;
switch (way_1)
{
case 1:
way[time_1] = '+';
break;
case 2:
way[time_1] = '-';
break;
case 3:
way[time_1] = '*';
break;
case 4:
way[time_1] = '/';
break;
}
}

if (way[0] == '+' || way[1] == '+')
{
result = number[0] + number[1] + number[2];
}

if (way[0] == '+' || way[1] == '-')
{
result = number[0] + number[1] - number[2];
}

if (way[0] == '+' || way[1] == '*')
{
result = number[0] + (number[1] * number[2]);
}

if (way[0] == '+' || way[1] == '/')
{
result = number[0] + (number[1] / number[2]);
}

if (way[0] == '-' || way[1] == '+')
{
result = number[0] - number[1] + number[2];
}

if (way[0] == '-' || way[1] == '-')
{
result = number[0] - number[1] - number[2];
}

if (way[0] == '-' || way[1] == '*')
{
result = number[0] - (number[1] * number[2]);
}

if (way[0] == '-' || way[1] == '/')
{
result = number[0] - (number[1] / number[2]);
}

if (way[0] == '*' || way[1] == '+')
{
result =( number[0] * number[1]) + number[2];
}

if (way[0] == '*' || way[1] == '-')
{
result = (number[0] * number[1] )- number[2];
}

if (way[0] == '*' || way[1] == '*')
{
result = number[0] * number[1] * number[2];
}

if (way[0] == '*' || way[1] == '/')
{
result = number[0] * (number[1] / number[2]);
}

if (way[0] == '/' || way[1] == '+')
{
result = (number[0] / (number[1]) + number[2]);
}

if (way[0] == '/' || way[1] == '-')
{
result = (number[0] / (number[1]) - number[2]);
}

if (way[0] == '/' || way[1] == '*')
{
result = (number[0] / number[1]) * number[2];
}

if (way[0] == '/' || way[1] == '/')
{
result = (number[0] / number[1])/ number[2];
}

int check = (int)result;

if(result == check && result>0)
{
cout << number[0] << way[0] << number[1] << way[1] << number[2] << '=' << result <<endl;
total++;
}
}
}


对于该次源代码的上传，我选择在网页进行提交，通过查找教程和进行翻译来一点点的完成作业

感觉vs与git看起来都很复杂但在掌握之后却会觉得意外的方便，新的工具的出现可以大幅的提高个人的效率。尤其是vs其实比vc++6.0更为简单与方便也更有利于编程语言的学习。

posted on 2019-09-21 19:20  zero-one  阅读(190)  评论(1编辑  收藏  举报