C语言寒假大作战03

计科一班段誉 18:35:25

问题 答案
这个作业属于哪个课程 https://edu.cnblogs.com/campus/zswxy/CST2019-1
这个作业要求在哪里 https://edu.cnblogs.com/campus/zswxy/CST2019-1/homework/10272
我在这个课程的目标是 学习
作业正文 https:////www.cnblogs.com/sanying/p/12444178.html
其它参考文献 百度,简书

1.1.1设计思路和遇到的问题

1.2.1程序结果截图

C语言寒假大作战03_第1张图片
C语言寒假大作战03_第2张图片
C语言寒假大作战03_第3张图片

1.3.1程序代码

include

include

include

int menu();
int help();
int error();
int grade1(int a);
int grade2(int a);
int grade3(int a);
int main()
{
int m = -1, n = 0;
while (m != 0)
{
printf("========== 口算生成器 ==========\n");
printf("欢迎使用口算生成器 :\n");
printf("\n");
help();
printf("\n");
printf("\n");
menu();
scanf("%d", &n);
switch (n)
{
case 1:grade1(n); break;
case 2:grade2(n); break;
case 3:grade3(n); break;
case 4:help(); break;
case 5:printf("程序结束, 欢迎下次使用\n任意键结束……"); break;
default:error(); break;
}
}
}
int menu()
{
printf("操作列表:\n");
printf("1)一年级 2)二年级 3)三年级\n");
printf("4)帮助 5)退出程序\n");
printf("请输入操作> \n");
return 1;
}
int help()
{
printf("帮助信息\n");
printf("您需要输入命令代号来进行操作, 且\n");
printf("一年级题目为不超过十位的加减法;\n");
printf("二年级题目为不超过百位的乘除法;\n");
printf("三年级题目为不超过百位的加减乘除混合题目.\n");
return 1;
}
int error()
{
printf("Error!!!\n");
printf("错误操作指令, 请重新输入\n");
return 1;
}
int grade1(int a)
{
int n, i, b, c, d;
char op;
srand((unsigned)time(NULL));
printf("现在是一年级题目\n");
printf("请输入生成个数>\n");
scanf("%d", &n);
printf("<执行操作:)\n");
for (i = 0; i < n; i++)
{
b = rand() % 2;
if (b == 0)
op = '-';
if (b == 1)
op = '+';
c = rand() % 10;
d = rand() % 10;
printf("%2d %c %2d = ___\n", c, op, d);
}
printf("执行完了(小声,假装这里有操作\n");
return 1;
}
int grade2(int a)
{
int i, n, b, c, d;
char op;
srand((unsigned)time(NULL));
printf("现在是二年级题目\n");
printf("请输入生成个数>\n");
scanf("%d", &n);
printf("<执行操作:)\n");
for (i = 0; i < n; i++)
{
b = rand() % 2;
if (b == 0)
op = '';
if (b == 1)
op = '/';
c = rand() % 10;
d = rand() % 10;
if (op == '/' && d == 0)
d = rand() % 9 + 1;
printf("%2d %c %2d = ___\n", c, op, d);
}
printf("执行完了(小声,假装这里有操作\n");
return 1;
}
int grade3(int a)
{
int n, i, b, c, d, e, f;
char op1, op2;
printf("<执行操作:)\n");
printf("现在是三年级题目\n");
printf("请输入生成个数>\n");
scanf("%d", &n);
printf("<执行操作:)\n");
for (i = 0; i < n; i++)
{
b = rand() % 4;
if (b == 0)
op1 = '-';
if (b == 1)
op1 = '+';
if (b == 2)
op1 = '
';
if (b == 3)
op1 = '/';
c = rand() % 100;
d = rand() % 100;
if (op1 == '/' && d == 0)
d = rand() % 99 + 1;
e = rand() % 4;
if (e == 0)
op2 = '-';
if (e == 1)
op2 = '+';
if (e == 2)
op2 = '*';
if (e == 3)
op2 = '/';
f = rand() % 100;
if (op2 == '/' && f == 0)
f = rand() % 99 + 1;
printf("%2d %c %2d %c %2d = ___\n", c, op1, d, op2, f);
}
printf("执行完了(小声,假装这里有操作\n");
return 1;
}

1.4.1Gitee上传截图与链接

你可能感兴趣的:(C语言寒假大作战03)