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 <stdlib.h>
# include <stdio.h>
# include <conio.h>
# include <string.h>
# include <time.h>
# include <windows.h>
struct student_info
{
char id [ 15 ] ;
char name [ 10 ] ;
int p ;
} ;
int * o ;
int add = 0 ;
void MainMenu ( ) ;
void Searchgrade ( ) ;
int main ( )
{
printf ( " 考生须知: \n " ) ;
printf ( " 1每道题学生有三次机会输入答案, 当学生输入错误答案时, 提醒学生重新输入, 如果三次机会结束则输出正确答案; \n " ) ;
printf ( " 2对于每道题, 学生第一次输入正确答案得10分, 第二次输入正确答案得7分, 第三次输入正确答案得5分, 否则不得分。 \n " ) ;
MainMenu ( ) ;
Searchgrade ( ) ;
}
void ClearScreen ( int j )
{
for ( ; j > 0 ; j - - )
{
Sleep ( 1000 ) ;
printf ( " %d \n " , j ) ;
} //时间函数
system ( " cls " ) ;
}
void MainMenu ( )
{
system ( " color f4 " ) ;
struct student_info stu [ 1 ] ;
printf ( " 1请输入你的学号: " ) ;
gets ( stu [ 1 ] . id ) ;
printf ( " 2请输入你的姓名: " ) ;
gets ( stu [ 1 ] . name ) ;
printf ( " 3请输入你所在的班级: " ) ;
scanf ( " %d " , & stu [ 1 ] . p ) ;
printf ( " 下面正式开始考试,倒计时五秒,请做好准备! \n " ) ;
ClearScreen ( 5 ) ;
srand ( time ( NULL ) ) ;
int q = 0 ;
int num = 0 ;
int score [ 3 ] = { 10 , 7 , 5 } ;
char str [ 100 ] , str1 [ 100 ] [ 100 ] ;
while ( 1 )
{
int a = 0 , b = 0 , d = 0 , c = 0 , k = 0 , i = 0 , j = - 1 ;
int result ;
char sf [ 2 ] = { ' + ' , ' - ' } ;
while ( 1 )
{
a = rand ( ) % 51 ;
b = rand ( ) % 51 ;
d = rand ( ) % 2 ;
if ( d = = 0 )
c = a + b ;
else
c = a - b ;
if ( c > = 0 & & c < = 50 )
{
sprintf ( str , " %d %c %d = \n " , a , sf [ d ] , b ) ;
strcpy ( str1 [ num ] , str ) ;
if ( num = = 0 )
{
break ; }
j = - 1 ;
for ( i = 0 ; i < num ; i + + )
{
if ( strcmp ( str , str1 [ i ] ) = = 0 )
{ j = 1 ; break ; }
}
if ( j < 0 )
break ;
}
}
printf ( " %s \n " , str ) ;
printf ( " 输入计算结果: \n " ) ;
while ( 1 )
{
scanf ( " %d " , & result ) ;
k + + ;
if ( result = = c )
{
printf ( " 回答正确! " ) ;
add + = score [ k - 1 ] ;
printf ( " (你已经答对%d道题) \n " , + + q ) ;
break ;
}
else if ( k < 3 )
{
printf ( " 错误,请重新回答: \n " ) ;
}
else
{
printf ( " 错误,正确答案: %d \n " , c ) ;
break ;
}
}
num + + ;
if ( num < 10 )
{
printf ( " 三秒后进入下一题 \n " ) ;
ClearScreen ( 3 ) ;
}
else
break ;
}
o = & add ;
if ( add > = 90 )
printf ( " \n 你的评分为SMART \n " ) ;
else if ( add > = 80 )
printf ( " \n 你的评分为GOOD \n " ) ;
else if ( add > = 70 )
printf ( " \n 你的评分为OK \n " ) ;
else if ( add > = 60 )
printf ( " \n 你的评分为PASS \n " ) ;
else printf ( " \n 你的评分为TRY AGAIN \n " ) ;
getch ( ) ;
}
void Searchgrade ( )
{
int q = 1 ;
int w = 0 ;
int e ;
printf ( " 你是否想知道你考试的具体成绩? \n " ) ;
printf ( " 想知道请输入1, 不想知道请输入0 \n " ) ;
scanf ( " %d " , & e ) ;
if ( e = = 1 )
printf ( " %d " , * o ) ;
if ( e = = 0 )
printf ( " 谢谢! " ) ;
}
void pit ( )
{
printf ( " 考生须知: \n " ) ;
printf ( " 1每道题学生有三次机会输入答案, 当学生输入错误答案时, 提醒学生重新输入, 如果三次机会结束则输出正确答案; \n " ) ;
printf ( " 2对于每道题, 学生第一次输入正确答案得10分, 第二次输入正确答案得7分, 第三次输入正确答案得5分, 否则不得分。 " ) ;
}