:小学生数学测试系统 20C

1、基本功能:
(1)主界面设计,选择练习或测试。
(2)题型选择界面设计,选择加、减、乘、除或混合运算。
(3)系统随机出题,运算数及结果均在100以内,除法应能整除,显示算式。
(4)练习时,系统随机出题,键入结果,正确和错误均有提示,出错时允许再输入,
最多二次机会,若还不正确,给出答案。继续出题,按ESC,显示总题数,正确数和
正确率。
(5)测试时,系统自动出10道题,每题只给一次机会,每题10分,统计得分。结束
后,给出总分,显示各题的对错信息,错误的给出答案。
2. 扩展功能:
 (1)测试时不能有重题。

2个回答

#include <stdlib.h> 
#include <stdio.h> 
#include <time.h> 
int question_get(); 
int type; 
void main( void ) 
{ 
int answer,n; 
srand( (unsigned)time( NULL ) ); 
loop: 
printf( "请选择要进行测试的题目种类:" ); 
scanf( "%d", &type ); 
while( 1 ) 
{ 
int temp; 
int flag; 

answer = question_get(); 
printf( "请回答:\n" ); 
scanf( "%d", &temp ); 
while( temp!=answer ) 
{ 
printf( "\n答案错误,重做\n" ); 
scanf( "%d", &temp ); 
} 
printf( "\n答案正确,很好\n" ); 
printf( "继续请按1,退出请按0\n" ); 
scanf( "%d", &flag ); 
while( flag!=0&&flag!=1 ) 
{ 
printf( "按其它键无效\n" ); 
scanf( "%d", &flag ); 
} 
if( flag==0 ) 
break; 
goto loop; 
} 
} 
int question_get() 
{ 
int a,b,c; 
loop: if( type==1 ) 
{ 
a=rand()%99; 
b=99-a; 
b=rand()%b; 
printf( "%d + %d = ?", a, b ); 
return(a+b); 
} 
else if( type==2 ) 
{ 
b=rand()%99; 
c=99-b; 
c=rand()%c; 
printf( "%d - %d = ?", b+c, b ); 
return(c); 
} 
else if( type==3 ) 
{
a=rand()%10; 
b=50-a; 
b=rand()%b; 
printf( "%d * %d = ?", a, b ); 
return(a*b); 
} 
else if( type==4 ) 
{ 
b=rand()%50; 
c=100/b; 
while( 1 ) 
{ 
c=rand()%c; 
if( c!=0 ) 
break; 

} 
printf( "%d / %d = ?", b*c, b ); 

return(c); 
} 
else if( type==5 ) 
{ 

printf("\t\t\t退出系统\n"); /*结束程序*/ 

system("pause"); 
exit(0); 
} 
else if( type==0||type>5 ) 
{ 

printf("\t\t\t输入错误,请输入1-5内的数字\n"); 
printf("\t\t\t请选择(1-5):"); 
scanf( "%d", &type ); 
goto loop; 

} 
} 
printf( "\n1.加法运算\n2.减法运算\n3.乘法运算\n4.除法运算\n5.退出运算\n" ); 
printf("\t\t\t请选择(1-5):"); 
} 

#include
#include
#include
int question_get();
int type;
void main( void )
{
int answer,n;
srand( (unsigned)time( NULL ) );
loop:
printf( "请选择要进行测试的题目种类:" );
scanf( "%d", &type );
while( 1 )
{
int temp;
int flag;

answer = question_get();
printf( "请回答:\n" );
scanf( "%d", &temp );
while( temp!=answer )
{
printf( "\n答案错误,重做\n" );
scanf( "%d", &temp );
}
printf( "\n答案正确,很好\n" );
printf( "继续请按1,退出请按0\n" );
scanf( "%d", &flag );
while( flag!=0&&flag!=1 )
{
printf( "按其它键无效\n" );
scanf( "%d", &flag );
}
if( flag==0 )
break;
goto loop;
}
}
int question_get()
{
int a,b,c;
loop: if( type==1 )
{
a=rand()%99;
b=99-a;
b=rand()%b;
printf( "%d + %d = ?", a, b );
return(a+b);
}
else if( type==2 )
{
b=rand()%99;
c=99-b;
c=rand()%c;
printf( "%d - %d = ?", b+c, b );
return(c);
}
else if( type==3 )
{
a=rand()%10;
b=50-a;
b=rand()%b;
printf( "%d * %d = ?", a, b );
return(a*b);
}
else if( type==4 )
{
b=rand()%50;
c=100/b;
while( 1 )
{
c=rand()%c;
if( c!=0 )
break;

}
printf( "%d / %d = ?", b*c, b );

return(c);
}
else if( type==5 )
{

printf("\t\t\t退出系统\n"); /*结束程序*/

system("pause");
exit(0);
}
else if( type==0||type>5 )
{

printf("\t\t\t输入错误,请输入1-5内的数字\n");
printf("\t\t\t请选择(1-5):");
scanf( "%d", &type );
goto loop;

}
}
printf( "\n1.加法运算\n2.减法运算\n3.乘法运算\n4.除法运算\n5.退出运算\n" );
printf("\t\t\t请选择(1-5):");
}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问