#include
#include
void main()
{
void fuhao(int x) ;
int a,b,t,p,score,flag; score=0;
loop :printf("开始进入测试!\n");
for(int i=0;i<10;i++)
{
printf("第%d题:\n",i+1);
a=rand()%10;
b=rand()%10;
if(a{t=a;a=b;b=t;}
flag=rand()%2;
printf("%d",a);
fuhao(flag);
printf("%d=\n",b);
scanf("%d",&t);
if(flag==0)
{
if(t==a+b)
{printf("真棒了! 答对了!\n");score=score+10;}
if(t!=a+b)printf("答错了!正确答案是:%d\n",a+b);
}
if(flag==1)
{
if(t==a-b)
{printf("真棒了! 答对了!\n");score=score+10;}
if(t!=a-b)printf("答错了!正确答案是:%d\n",a-b);
}
}
printf("最后得分:%d\n",score);
printf("是否继续?1.继续2.退出\n");
scanf("%d",&t);
if(t==1)goto loop;
else printf("欢迎使用!再见!");
}
void fuhao(int x)
{
if(x==0) printf("+");
if(x==1) printf("-");
}
界面没有仔细处理,应该还能看的过去吧
#include
#include
#include
#include
#define NOU 10/*试题数量*/
int comp(int);
int init(void);
int main(int argc, char* argv[])
{
int in;
do
{
init();
scanf("%d",&in);
assert(in>=0&&in<=4);
system("cls");
if (in) comp(in);
}
while (in!=0);
return 0;
}
int init(void)
{
system("cls");
printf("1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n0. EXIT\n");
return 0;
}
int comp(int op)
{
int a,b,c,i,right=0;
float cfd;
printf("Input \'-1\' to exit!\n\n");
srand(time(NULL));
for (i = 0; i < NOU; i++) {
a=rand()%10+1;
b=rand()%10+1;
switch(op){
case 1:printf("%d+%d=",a,b);
b=a+b;
break;
case 2:while (a-b<0) {
a=rand()%10+1;
b=rand()%10+1;
}
printf("%d-%d=",a,b);
b=a-b;
break;
case 3:printf("%d*%d=",a,b);
b=a*b;
break;
case 4:while (aa=rand()%10+1;
b=rand()%10+1;
cfd=a/b;
}
printf("%d/%d=",a,b);
b=a/b;
break;
}
scanf("%d",&c);
b==c?printf("\nRight!\n"):printf("\nWrong! It's %d\n",b);
right+=b==c?1:0 ;
}
puts("****************************");
printf("Right:\t%d\nWrong:%d\n",right,10-right);
system("pause");
return 0;
}
#include
#include
#include
int main()
{
char ch;
//while(1)
{
printf("---------\n");
printf("做题请按g\n");
printf("退出请按x\n");
printf("---------\n");
scanf("%c",&ch);
getchar();
if(ch=='x')
{
break;
}
else if(ch=='g')
{
int x,y,op,r,input;
x=rand()%10;
y=rand()%10;
switch(rand()%2)
{
case 0:
op='+';
r=x+y;
break;
default:
op='-';
if(x
r=x;
x=y;
y=r;
}
r=x-y;
break;
}
printf("%d%c%d=",x,op,y);
scanf("%d",&input);
if(input==r)
{
printf("真聪明,做对啦!\n");
}
else
{
printf("好笨啊,做错啦!\n");
}
printf("\n");
}
}
return 0;
}