第二次作业
| GIt地址 | https://github.com/lucky432/Calculator |
|---|---|
| GIt用户名 | lucky432 |
| 学号后五位 | 61328 |
| 博客地址 | https://www.cnblogs.com/a1290389465/ |
| 作业链接 | https://edu.cnblogs.com/campus/xnsy/Autumn2019SoftwareEngineeringFoundation/homework/7590 |
环境配置过程
vs2017安装配置
(ed2k://|file|mu_visual_studio_community_2017_version_15.3_x86_x64_11100062.exe|1069960|5984B3CD547F9F213DE21EFE5887F08D|/) 迅雷下载安装安装器,之后下载,成功陪之后打开如图:(在下载时速度很慢,迫不得已去图书馆,配置时无什么大问题。2.在安装时路径问题须注意不然后期会很恼火!)
下载好安装软件后打开,如下图:

之后选择c++桌面开发,进行安装

进入git下载下载安装,过程如图

进入时

(git配置时由于很简单,无什么问题)
代码思路:
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
char op() /*随机生成运算符函数*/
{
int x;
srand((unsigned)time(NULL));
x = rand() % 4 + 1;
switch (x)
{
case 1:
return '+';
case 2:
return '-';
case 3:
return '*';
case 4:
return '/';
}
}
void set(int &x) /*生成随机数字,并且调用运算符生成函数生成算式*/
{
int a, b, c, d;
int m,n,l;
int i = 0;
srand((unsigned)time(NULL));
while (i < x)
{
a = rand() % 100 + 1;
b = rand() % 100 + 1;
c = rand() % 100 + 1;
n = rand() % 2 + 1;
m = a / b;
l = b / c;
char j,k;
j = op();
k = op();
if (n == 1)
{
if (j == '/')
{
if (m*b == a)
{
cout << a << j << b << "="<<endl;
i++;
continue;
}
}
else if(j=='-')
{
if(a-b>=0)
{cout << a << j << b << "="<<endl;
i++;
continue;}
else
continue;
}
else
cout << a << j << b << "="<<endl;
}
if (n == 2)
{
if (j == '/' || k == '/')
{
if (m*b == a && l * c == b)
{
cout << a << j << b << "="<<endl;
i++;
continue;
}
else
continue;
}
else
{cout << a << j << b << "="<<endl;
i++;
continue;}
}
else
continue;
}
}
int main()
{
int n;
cout << "输入打印题目的数量:" << endl;
cin >> n;
set(n);
return 0;
}
运行结果如图:

克隆和提交:
git网址复制进入网址点击fork,如图

之后点击 clone of download ,复制地址。然后打开 git 复制,如图

之后打开vs2017,按步骤建立文件夹。
代码正常运行和目标纯在差异,没能调试正确,所以 提交测试步骤省略
问题与思考总结
本次作业存在一定难度 ,主要体现在对新工具的不熟悉,以及文件紊乱导致的软件不能正常运行,这深刻的让自己感到乏力。但不管怎样,自己也算是在此次作业中得到了一定的收获,虽然小但很有意义!同时本次作业的问题希望大家注意,在编写一个程序时注意程序的测试,以确保程序的质量,同时合理安排自己的编程时间,不要因为时间和自己代码问题影响到程序的编写!![]

浙公网安备 33010602011771号