任务1
#include
#include
#include
int main()
{
int m,n,counter=0,p,x;
srand(time(NULL));
m=rand()%10+1;
n=rand()%10+1;
do{
p=m*n;
printf("%d*%d=?\n",m,n);
scanf("%d",&x);
if(p==x)
printf("Right!\n");
if(p!=x)
{
printf("Wrong! Please try again.\n");
}
}while(x!=p);
return 0;
}
任务2
#include
#include
#include
int main()
{
int m,n,counter=0,p,x;
srand(time(NULL));
m=rand()%10+1;
n=rand()%10+1;
do{
p=m*n;
printf("%d*%d=?\n",m,n);
scanf("%d",&x);
if(p==x)
printf("Right!\n");
if(p!=x)
{
counter++;
if(counter<=2)
{
printf("Wrong! Please try again.\n");
}
else
printf("Wrong!You have tried three times! Test over!\n");
}
}while(x!=p&&counter<3);
return 0;
}
任务三
#include
#include
#include
int main()
{
int m,n,counter=0,p,x;
float l=0,k;
srand(time(NULL));
do{
m=rand()%10+1;
n=rand()%10+1;
p=m*n;
printf("%d*%d=?\n",m,n);
scanf("%d",&x);
counter++;
if(p==x)
{
l++;
printf("Right!\n");
}
if(p!=x)
{
printf("Wrong!\n");
}
}while(counter<10);
k=100*(float(l)/10);
printf("正确率:%.f%%\n",k);
return 0;
}
任务四
#include
#include
#include
int main()
{
system("color 5F");
int m,n,counter=0,p,x,y,t,term,v;
float l=0,k;
char h;
srand((unsigned)time(NULL));
srand(time(NULL));
do{
t=rand()%4;
m=rand()%10+1;
n=rand()%10+1;
if(t==0)
{
h='+';
p=m+n;
}
if(t==1)
{
h='-';
if(m=0)
v=0;
}
}while(v==1);
counter++;
if(p==x)
{
l++;
printf("Right!\n");
}
if(p!=x)
{
printf("Wrong!\n");
}
}while(counter<10);
k=100*(float(l)/10);
printf("正确率:%.f%%\n您的分数为%.f\n",k,k);
return 0;
}
任务五
#include
#include
#include
int main()
{
system("color 5F");
int m,n,counter=0,p,x,y,t,term,v;
float l=0,k;
char h;
srand((unsigned)time(NULL));
srand(time(NULL));
do{
do{
t=rand()%4;
m=rand()%10+1;
n=rand()%10+1;
if(t==0)
{
h='+';
p=m+n;
}
if(t==1)
{
h='-';
if(m=0)
v=0;
}
}while(v==1);
counter++;
if(p==x)
{
l++;
printf("Right!\n");
}
if(p!=x)
{
printf("Wrong!\n");
}
}while(counter<10);
k=100*(float(l)/10);
printf("正确率:%.f%%\n您的分数为%.f\n",k,k);
counter=0,l=0;
if(k<75)
printf("您的正确率不到75%%,请在做一遍.\n");
}while(k<75);
return 0;
}
任务六
#include
#include
#include
int main()
{
system("color 5F");
int m,n,counter=0,p,x,y,t,term,v;
float l=0,k;
char h;
srand((unsigned)time(NULL));
srand(time(NULL));
do{
do{
t=rand()%4;
m=rand()%10+1;
n=rand()%10+1;
if(t==0)
{
h='+';
p=m+n;
}
if(t==1)
{
h='-';
if(m=0)
v=0;
}
}while(v==1);
counter++;
if(p==x)
{
l++;
if(t==0)
printf("Very good!\n");
if(t==1)
printf("Excellent!\n");
if(t==2)
printf("Nice work!\n");
if(t==3)
printf("Keep up the good work!\n");
}
if(p!=x)
{
if(t==0)
printf("No.Please try again.\n");
if(t==1)
printf("Wrong.Try once more.\n");
if(t==2)
printf("Don't give up\n");
if(t==3)
printf("Not correct.Keep trying.\n");
}
}while(counter<10);
k=100*(float(l)/10);
printf("正确率:%.f%%\n您的分数为%.f\n",k,k);
counter=0,l=0;
if(k<75)
printf("您的正确率不到75%%,请在做一遍.\n");
}while(k<75);
return 0;
}