给小学生编写练习20以内加,减法
#include
#include
int mark=0,number=0,right=0,wrong=0,x;
put_out(char k)
{
int a,b,c,x,flag=1;
if(k=='+')
{
while(flag==1)
{
a=srand(21);
b=random(21);
c=a+b;
if(c=0)
{
flag=0;
printf("%d-%d=",a,b);
}
}
x=a-b;
}
return(x);
}
int judge_answer(int answer,int x)
{
int a;
printf("\nPlease put in your...全部
#include
#include
int mark=0,number=0,right=0,wrong=0,x;
put_out(char k)
{
int a,b,c,x,flag=1;
if(k=='+')
{
while(flag==1)
{
a=srand(21);
b=random(21);
c=a+b;
if(c=0)
{
flag=0;
printf("%d-%d=",a,b);
}
}
x=a-b;
}
return(x);
}
int judge_answer(int answer,int x)
{
int a;
printf("\nPlease put in your answer:");
scanf("%d",&answer);
if(answer==x)
{
printf("\nthat is right!");
right++;
mark=right*10;
printf("\nyour mark is %d\n",mark);
}
else
{
wrong++;
printf("\nthat is not correct!");
printf("\nyour mark is %d\n",mark);
}
a=answer;
return(a);
}
void result()
{
printf("you have complete %d problems!\nRight number:%d!\nWrong number:%d!\nand your score is:%d!",number,right,wrong,mark);
}
void main()
{
int j,answer;
char k,e;
printf("please choose the aigorithm:('+'or'-')");
scanf("%s",&k);
for(number=0;number5)
{
printf("exit or not (Y/N)?");
getchar();
e=getchar();
}
if(e=='y'||e=='Y')
break;
}
result();
}。
收起