啊哈磊_编程从这里起步
标题:
你们看我的这个程序怎么样
[打印本页]
作者:
德
时间:
2020-8-26 16:24
标题:
你们看我的这个程序怎么样
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>
int main()
{
int Hs;
printf("请选择难度:1等/2等(1等更难)");
scanf("%d",&Hs);
switch(Hs)
{
case 1:
Hs=four();
break;
case 2:
Hs=three();
break;
default:
printf("输入错误,你只有重进了");
}
system("pause");
return 0;
}
int four(void)
{
int a1,a2,a3,a4,b,c1,c2,c3,c4,c,z1,z2,z3,z4,oa2,od,oa4;
puts("请稍等");
srand((unsigned)time(NULL));
a1=rand()%10;
Sleep(500);
srand((unsigned)time(NULL));
a2=rand()%10;
Sleep(500);
srand((unsigned)time(NULL));
a3=rand()%10;
Sleep(500);
srand((unsigned)time(NULL));
b=rand()%10;
Sleep(500);
srand((unsigned)time(NULL));
a4=rand()%10;
Sleep(500);
c1=b*a4%10;
z1=(b*a4)/10;
c2=b*a3%10+z1;
z2=(b*a3)/10;
c3=b*a2%10+z2;
z3=(b*a2)/10;
c4=b*a1%10+z3;
z4=(b*a1)/10;
c=z4*10000+c4*1000+c3*100+c2*10+c1;
system("color a0");
printf("%d * %d @",a1,a3);
printf("x #");
printf("---------- ",z2,z1);
printf("%d ",c);
printf("*,@,#里各填什么?按顺序每个填完后按空格 谨慎填写 :");
scanf("%d%d%d",&oa2,&oa4,&od);
if(oa2==a2&&oa4==a4&&od==b)
{
system("color ce");
printf("答对了!!!");
}
else
{
system("color 10");
printf("错了! 正确答案是: %d%d%d%d*%d=%d",a1,a2,a3,a4,b,c);
Sleep(3000);
exit(0);
}
return 0;
}
int three(void)
{
int a1,a2,a3,b,c1,c2,c3,c,z1,z2,z3,oa2,od,Hs;
puts("请稍等");
srand((unsigned)time(NULL));
a1=rand()%10;
Sleep(1000);
srand((unsigned)time(NULL));
a2=rand()%10;
Sleep(1000);
srand((unsigned)time(NULL));
a3=rand()%10;
Sleep(1000);
srand((unsigned)time(NULL));
b=rand()%10;
Sleep(1000);
c1=b*a3%10;
z1=(b*a3)/10;
Sleep(1000);
c2=b*a2%10+z1;
z2=(b*a2)/10;
c3=b*a1%10+z2;
z3=(b*a1)/10;
c=z3*1000+c3*100+c2*10+c1;
system("color a0");
printf("%d * %d",a1,a3);
printf("x #");
printf("------ )",z2,z1);
printf("%d ",c);
printf("*和#里各填什么?按顺序每个填完后按空格 谨慎填写 :");
scanf("%d%d",&oa2,&od);
if(oa2==a2&&od==b)
{
printf("答对了!!!");
}
else
{
printf("错了! 正确答案是:");
printf("%d%d%d*%d=%d",a1,a2,a3,b,c);
Sleep(3000);
exit(0);
}
return 0;
}
复制代码
欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/)
Powered by Discuz! X3.2