C语言寒假大作战04

这个作业属于哪个课程 https://edu.cnblogs.com/campus/zswxy/SE2019-2/
这个作业要求在哪里 https://edu.cnblogs.com/campus/zswxy/SE2019-2/homework/10275
这个作业的目标 把计算题答案显示出来
作业正文 https://www.cnblogs.com/qwe741741741/p/12317934.html
其他参考文献 %d与%g

2.2.2 设计思路和遇到的问题
利用%d与%g来显示答案
2.2.3 程序结果截图
C语言寒假大作战04_第1张图片
C语言寒假大作战04_第2张图片
C语言寒假大作战04_第3张图片

2.2.4 程序代码

include

include

include

void one();
void two();
void three();
void help();
void error();
void menu();

int main()
{
printf("========口算生成器========\n");
printf("欢迎使用口算生成器:\n");
int command;

while(command !=5)
{
    printf("\n");
    printf("帮助信息\n");
    printf("您需要输入命令代号来进行操作,且\n");
    printf("一年级题目为不超过十位的加减法;\n");
    printf("二年级题目为不超过百位的乘除法;\n");
    printf("三年级题目为不超过百位的加减乘除混合题目;\n");
    printf("\n");
    menu();
    scanf("%d",&command);
    switch(command)
    {
        case 1:one();break;
        case 2:two();break;
        case 3:three();break;
        case 4:help();break;
        printf("程序结束,欢迎下次使用任意键结束   \n");break;
        default:error();break;
    }
}

}

void one()
{
printf("执行操作>\n");
printf("现在是一年级题目\n");
printf("请输入生成个数");
int x,y,X,Y,Z;
time_t t;
srand((unsigned)time(&t));
char symbol[2] = {'+','-'};
scanf("%d",&x);
for(y=0;y {
X=rand()%10;
Y=rand()%10;
Z=symbol[rand()%2];
if(Z=='+')
{
printf("%d + %d = %g\n",X,Y,(double)X+Y);
}
else
{
printf("%d - %d = %g\n",X,Y,(double)X-Y);
}

}

}

void two()
{
printf("执行操作>\n");
printf("现在是二年级题目\n");
printf("请输入生成个数");
int a,b,A,B,Z;
time_t t;
srand((unsigned)time(&t));
char symbol[2] = {'','/'};
scanf("%d",&a);
for(b=0;b {
A=rand()%99;
B=rand()%99;
Z=symbol[rand()%2];
if(Z=='
')
{
printf("%d * %d = %g\n",A,B,(double)A*B);
}
else
{
printf("%d / %d = %g\n",A,B,(double)A/B);
}
}
}

void three()
{
printf("执行操作>\n");
printf("现在是三年级题目\n");
printf("请输入生成个数");
int c,d,e,f,g,Z1,Z2;
time_t t;
srand((unsigned)time(&t));
char symbol[4] = {'','/','+','-'};
scanf("%d",&c);
for(d=0;d {
e=rand()%99;
f=rand()%99;
g=rand()%99;
Z1=symbol[rand()%4];
Z2=symbol[rand()%4];
if(Z1=='+'&&Z2=='+')
{
printf("%d + %d + %d = %g\n",e,f,g,(double)e+f+g);
}
else if(Z1=='+'&&Z2=='-')
{
printf("%d + %d - %d = %g\n",e,f,g,(double)e+f-g);
}
else if(Z1=='+'&&Z2=='
')
{
printf("%d + %d * %d = %g\n",e,f,g,(double)e+fg);
}
else if(Z1=='+'&&Z2=='/')
{
printf("%d + %d / %d = %g\n",e,f,g,(double)e+f/g);
}
else if(Z1=='-'&&Z2=='+')
{
printf("%d - %d + %d = %g\n",e,f,g,(double)e-f+g);
}
else if(Z1=='-'&&Z2=='-')
{
printf("%d - %d - %d = %g\n",e,f,g,(double)e-f-g);
}
else if(Z1=='-'&&Z2=='
')
{
printf("%d - %d * %d = %g\n",e,f,g,(double)e-fg);
}
else if(Z1=='-'&&Z2=='/')
{
printf("%d - %d / %d = %g\n",e,f,g,(double)e-f/g);
}
else if(Z1=='
'&&Z2=='+')
{
printf("%d * %d + %d = %g\n",e,f,g,(double)ef+g);
}
else if(Z1=='
'&&Z2=='-')
{
printf("%d * %d - %d = %g\n",e,f,g,(double)ef-g);
}
else if(Z1=='
'&&Z2=='')
{
printf("%d
%d * %d = %g\n",e,f,g,(double)efg);
}
else if(Z1==''&&Z2=='/')
{
printf("%d
%d / %d = %g\n",e,f,g,(double)ef/g);
}
else if(Z1=='/'&&Z2=='+')
{
printf("%d / %d + %d = %g\n",e,f,g,(double)e/f+g);
}
else if(Z1=='/'&&Z2=='-')
{
printf("%d / %d - %d = %g\n",e,f,g,(double)e/f-g);
}
else if(Z1=='/'&&Z2=='
')
{
printf("%d / %d * %d = %g\n",e,f,g,(double)e/f*g);
}
else if(Z1=='/'&&Z2=='/')
{
printf("%d / %d / %d = %g\n",e,f,g,(double)e/f/g);
}

}

}

void help()
{
printf("请自力更生");
}

void error()
{
printf("Error!!!\n");
printf("错误操作指令,请重新输入");
}

void menu()
{
printf("操作列表:\n");
printf("1)一年级 2)二年级 3)三年级\n");
printf("4)四年级 5)退出程序\n");
printf("请输入操作>\n");
}

2.2.5 Gitee上传截图与链接

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