You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include <stdio.h>
# include <time.h>
# include <stdlib.h>
int question ( int i )
{
int a , b , j , m ;
for ( i = i ; i < 100 ; i + + )
{
loop :
{
a = rand ( ) % 51 ;
b = rand ( ) % 51 ; //rand()%100表示取50以内的随机数
j = rand ( ) % 2 ; //j的值决定加减法
}
if ( j = = 0 )
{
m = a + b ;
if ( m < = 50 )
{
printf ( " %d+%d= \n " , a , b ) ;
}
else
goto loop ;
}
else
{
m = a - b ;
if ( m < = 50 & & m > = 0 )
{
printf ( " %d-%d= \n " , a , b ) ;
}
else
goto loop ;
}
break ;
}
return m ;
}
int main ( )
{
int modelanswer = 0 ;
int studentanswer = 0 ;
char str [ 20 ] ;
int grade = 0 ;
int n ;
printf ( " \n " ) ;
printf ( " ============================================================ \n " ) ;
printf ( " ====================50以内加减法测验系统==================== \n " ) ;
printf ( " ============================================================ \n " ) ;
printf ( " \n " ) ;
printf ( " 请输入你的名字: \n " ) ;
scanf ( " %s " , str ) ;
printf ( " \n 你好呀,%s小朋友, 欢迎进入50以内加减法测验系统。 \n " , str ) ;
printf ( " 每道题你有三次答题机会,如果三次机会结束则直接给出正确答案。 \n " ) ;
printf ( " \n 测试结束后会给出你的成绩以及相应评级。 \n " ) ;
printf ( " \n " ) ;
printf ( " ======================要注意细心哦~========================= \n \n " ) ;
for ( n = 1 ; n < 11 ; n + + )
{
printf ( " \n 第%d道题: \n " , n ) ;
modelanswer = question ( n ) ;
printf ( " 请输入答案: " ) ;
scanf ( " %d " , & studentanswer ) ;
if ( studentanswer = = modelanswer )
{
printf ( " 回答正确,请继续加油哦。 \n " ) ;
grade = grade + 10 ;
}
else
{
printf ( " 回答错误,请好好思考。你还有两次机会。 \n " ) ;
printf ( " 请输入答案: " ) ;
scanf ( " %d " , & studentanswer ) ;
if ( studentanswer = = modelanswer )
{
printf ( " 回答正确,请继续加油哦。 \n " ) ;
grade = grade + 7 ;
}
else
{
printf ( " 回答错误,请好好思考。你还有一次机会。 \n " ) ;
printf ( " 请输入答案: " ) ;
scanf ( " %d " , & studentanswer ) ;
if ( studentanswer = = modelanswer )
{
printf ( " 回答正确,请继续加油哦。 \n " ) ;
grade = grade + 5 ;
}
else
{
printf ( " 回答错误。正确答案是:%d \n " , modelanswer ) ;
grade = grade + 0 ;
}
}
}
}
if ( grade > = 90 )
{
printf ( " \n SMART! \n " ) ;
}
if ( grade < 90 & & grade > = 80 )
{
printf ( " \n GOOD! \n " ) ;
}
if ( grade < 80 & & grade > = 70 )
{
printf ( " \n OK. \n " ) ;
}
if ( grade < 70 & & grade > = 60 )
{
printf ( " \n PASS. \n " ) ;
}
if ( grade < 60 )
{
printf ( " \n TRY AGAIN. \n " ) ;
}
printf ( " \n 你的成绩是:%d \n " , grade ) ;
return 0 ;
}