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 + + )
{
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 ) ;
}
if ( m > 50 ) continue ;
}
else
{
m = a - b ;
if ( m < = 50 & & m > = 0 )
{
printf ( " %d-%d= \n " , a , b ) ;
}
if ( m > 50 ) continue ;
}
break ;
}
return m ;
}
int main ( )
{
int ordinal = 1 ;
char str [ 10 ] ;
int score [ 3 ] = { 10 , 7 , 5 } ;
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 " ) ;
printf ( " 第一道题: \n \n " ) ;
question ( 1 ) ;
}