/************************************
CopyRight
Dragonpaopao
************************************/
#include
#include
#include
int
question_get();
int
type;
void
main(
void
)
{
int
answer;
srand(
(unsigned)time(
NULL
)
);
printf(
"请选择要进行测试的题目种类:"
);
printf(
"\n1.加法\n2.减法\n3.乘法\n4.除法\n"
);
scanf(
"%d",
&type
);
while(
1
)
{
int
temp;
char
flag;
answer
=
question_get();
printf(
"请给出你的答案:\n"
);
fflush(
stdin
);
scanf(
"%d",
&temp
);
while(
temp!=answer
)
{
printf(
"\n答案错误,重做\n"
);
fflush(
stdin
);
scanf(
"%d",
&temp
);
}
printf(
"\n答案正确,很好\n"
);
printf(
"继续请按1,退出请按0\n"
);
fflush(
stdin
);
scanf(
"%c",
&flag
);
while(
flag!='0'
&&
flag!='1'
)
{
printf(
"继续请按1,退出请按0\n按其它键无效\n"
);
fflush(
stdin
);
scanf(
"%c",
&flag
);
}
if(
flag=='0'
)
break;
}
}
int
question_get()
{
int
a,b,c;
if(
type==1
)
{
a=rand()%999;
b=999-a;
b=rand()%b;
printf(
"%d
+
%d
=
?",
a,
b
);
return(a+b);
}
else
if(
type==2
)
{
b=rand()%999;
c=999-b;
c=rand()%c;
printf(
"%d
-
%d
=
?",
b+c,
b
);
return(c);
}
else
if(
type==3
)
{
a=rand()%500;
b=1000/a;
b=rand()%b;
printf(
"%d
*
%d
=
?",
a,
b
);
return(a*b);
}
else
{
b=rand()%500;
c=1000/b;
while(
1
)
{
c=rand()%c;
if(
c!=0
)
break;
}
printf(
"%d
/
%d
=
?",
b*c,
b
);
return(c);
}
}
/************************************
CopyRight Dragonpaopao
************************************/
#include
#include
#include
int question_get();
int type;
void main( void )
{
int answer;
srand( (unsigned)time( NULL ) );
printf( "请选择要进行测试的题目种类:" );
printf( "\n1.加法\n2.减法\n3.乘法\n4.除法\n" );
scanf( "%d", &type );
while( 1 )
{
int temp;
char flag;
answer = question_get();
printf( "请给出你的答案:\n" );
fflush( stdin );
scanf( "%d", &temp );
while( temp!=answer )
{
printf( "\n答案错误,重做\n" );
fflush( stdin );
scanf( "%d", &temp );
}
printf( "\n答案正确,很好\n" );
printf( "继续请按1,退出请按0\n" );
fflush( stdin );
scanf( "%c", &flag );
while( flag!='0' && flag!='1' )
{
printf( "继续请按1,退出请按0\n按其它键无效\n" );
fflush( stdin );
scanf( "%c", &flag );
}
if( flag=='0' )
break;
}
}
int question_get()
{
int a,b,c;
if( type==1 )
{
a=rand()%999;
b=999-a;
b=rand()%b;
printf( "%d + %d = ?", a, b );
return(a+b);
}
else if( type==2 )
{
b=rand()%999;
c=999-b;
c=rand()%c;
printf( "%d - %d = ?", b+c, b );
return(c);
}
else if( type==3 )
{
a=rand()%500;
b=1000/a;
b=rand()%b;
printf( "%d * %d = ?", a, b );
return(a*b);
}
else
{
b=rand()%500;
c=1000/b;
while( 1 )
{
c=rand()%c;
if( c!=0 )
break;
}
printf( "%d / %d = ?", b*c, b );
return(c);
}
}