第1个回答 2011-05-17
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
//'+','-','*','/'分别为43,45,42,47
int RightAnswer;
int jisuan(int n[3])
{
int answer,x;
printf("%d%c%d=",n[0],n[1],n[2]);
scanf("%d",&answer);
if(answer==RightAnswer)
{
printf("Right!\n");
x=10;
}
else
{
printf("Wrong!\n");
x=0;
}
return x;
}
int main()
{
int n[3];
int i=0,scord=0,temp;
for(i=0;i<10;i++)
{
srand(time(0));
n[0]=rand()%10+1;
n[1]=rand()%4;
n[2]=rand()%10+1;
switch(n[1])
{
case 0:
RightAnswer=n[0]+n[2];
n[1]='+';
break;
case 1:
if(n[0]<n[2])
{
temp=n[2];
n[2]=n[0];
n[0]=temp;
}
RightAnswer=n[0]-n[2];
n[1]='-';
break;
case 2:
RightAnswer=n[0]*n[2];
n[1]='*';
break;
case 3:
RightAnswer=n[0]/n[2];
n[1]='/';
n[0]=n[0]-n[0]%n[2];
break;
}
scord+=jisuan(n);
}
printf("总分为:%d,答错了%d道",scord,10-scord/10);
return 0;
}
第2个回答 2017-08-01
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main(void){
unsigned int i,a,b;
srand((unsigned int)time(NULL));
for(i=0;i<10;i++)
{
a=rand()%10+1;
b=rand()%10+1;
printf("%d + %d = \n",a,b);
}
return 0;
}
第3个回答 2017-08-21
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main(void)
{
unsigned int i,a,b;
srand((unsigned int)time(NULL));
for(i=0;i<10;i++)
{
a=rand()%10+1;
b=rand()%10+1;
printf("%d + %d = \n",a,b);
}
return 0;
}//转自百度:
https://zhidao.baidu.com/question/268920227
第4个回答 2011-05-17
#include<stdlib.h>
#include<time.h>
//'+','-','*','/'分别为43,45,42,47
int RightAnswer;
int jisuan(int n[3])
{
int answer,x;
printf("%d%c%d=",n[0],n[1],n[2]);
scanf("%d",&answer);
if(answer==RightAnswer)
{
printf("Right!\n");
x=10;
}
else
{
printf("Wrong!\n");
x=0;
}
return x;
}
int main()
{
int n[3];
int i=0,scord=0,temp;
for(i=0;i<10;i++)
{
srand(time(0));
n[0]=rand()%10+1;
n[1]=rand()%4;
n[2]=rand()%10+1;
switch(n[1])
{
case 0:
RightAnswer=n[0]+n[2];
n[1]='+';
break;
case 1:
if(n[0]<n[2])
{
temp=n[2];
n[2]=n[0];
n[0]=temp;
}
RightAnswer=n[0]-n[2];
n[1]='-';
break;
case 2:
RightAnswer=n[0]*n[2];
n[1]='*';
break;
case 3:
RightAnswer=n[0]/n[2];
n[1]='/';
n[0]=n[0]-n[0]%n[2];
break;
}
scord+=jisuan(n);
}
printf("总分为:%d,答错了%d道",scord,10-scord/10);
return 0;