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.

283 lines
6.6 KiB

This file contains ambiguous Unicode characters!

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<stdlib.h>
#include<windows.h>
#include<time.h>
char reg_name[30]="",reg_pwd[10]="";
char on_name[30],on_pwd[10];
int t=0;
int judge(int a,int b)
{
if(a==b)
return 1;
else
return 0;
}
int mark(int a)
{
switch(a)
{
case 1:return 10;
case 2:return 7;
case 3:return 5;
case 4:return 0;
}
}
void again1()
{
printf("\n ******************************************\n");
printf(" **** 是否再来一次? ****\n");
printf(" **** 1.yes 2.no ****\n");
printf(" **** 输入1或2来选择是否重新考试 ****\n");
printf(" ******************************************\n ");
}
int again2()
{
int o;
scanf("%d",&o);
return o;
}
int random()
{
int a=rand()%51;
return a;
}
void test()
{
int p,q,t,s,j,m,sm=0;
for(int i=1;i<=10;i++)
{
p=random();
q=random();
if(p-q<0||p+q>50)
i--;
else
{
t=rand()%2;
if(t==1)
printf(" %-2d+%-2d=",p,q);
else
printf(" %-2d-%-2d=",p,q);
for(int i=1;i<=3;i++)
{
scanf("%d",&s);
if(t==1)
j=judge(s,p+q);
else
j=judge(s,p-q);
if(j==1)
{
m=mark(i);
break;
}
else
{
if(i<3)
printf(" 你还有%d次机会:",(3-i));
else
{
if(t==1)
printf(" 正确答案是%d\n",p+q);
else
printf(" 正确答案是%d\n",p-q);
m=mark(i+1);
}
}
}
sm+=m;
}
}
system("cls");
printf(" 你的成绩是%d\n",sm);
if(sm>90)
printf(" 你的评价是SMART");
if(sm>80&&sm<=90)
printf(" 你的评价是GOOD");
if(sm>70&&sm<=80)
printf(" 你的评价是OK");
if(sm>=60&&sm<=70)
printf(" 你的评价是PASS");
if(sm<60)
printf(" 你的评价是AGAIN");
}
void menu()
{
printf(" ******************************************\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** 1.开始考试 **\n");
printf(" ** **\n");
printf(" ** 2.退出考试 **\n");
printf(" ** **\n");
printf(" ** 3.考试说明 **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ******************************************\n");
printf(" 输入数字代表你的选择:");
}
int switch1()
{
int u;
scanf("%d",&u);
switch(u)
{
case 1:system("cls");return u;
case 2:system("cls");return u;
case 3:printf(" 说明:每个人有三次考试机会,选择退出之后不能再次重新考试。\n");
printf(" 做好考试准备之后请输入1\n ");
printf(" 退出考试请输入2\n ");
scanf("%d",&u);
system("cls");
return u;
}
}
void regist()
{
system("pause");
system("cls");
printf("\n\n 欢迎使用小学生测验系统\n\n");
while(1)
{
printf(" 请输入学号[不能大于10个字符]");
scanf("%s",reg_name);
if(strlen(reg_name)<=10)
{
while(1)
{
printf("\n 请输入密码[密码长度为八位]");
scanf("%s",reg_pwd);
if(strlen(reg_pwd)==8)
{
printf("\n\n 注册成功,您的用户名是%s,密码是%s\n\n",reg_name,reg_pwd);
break;
}
else
{
printf("\n 密码的长度为%d请重新输入\n",strlen(reg_pwd));
}
}
break;
}
else
{
printf("\n 用户名的长度为%d请重新输入\n\n",strlen(reg_name));
}
}
system("pause");
}
int judgereg()
{
if(strcmp(reg_name,"")==0&&strcmp(reg_pwd,"")==0)
{
printf("\n\n 您尚未注册,请先注册!\n\n");
return 0;
}
else
{
return 1;
}
}
void dl()
{
int i;
system("pause");
system("cls");
printf("\n\n 欢迎使用小学生测验系统\n\n");
for(i=1;i<=3;i++)
{
printf(" 请输入用户名:");
scanf("%s",on_name);
printf("\n 请输入密 码:");
scanf("%s",on_pwd);
if(strcmp(reg_name,on_name)==0&&strcmp(reg_pwd,on_pwd)==0)
{
printf("\n\n 登录成功,欢迎使用小学生测验系统\n\n");
system("pause");
t=1;
break;
}
else
{
printf("\n\n 登录失败,请重新登录,您还有%d次机会\n\n",3-i);
system("pause");
}
}
}
void start()
{
int id;
while(!t)
{
system("cls");
printf(" ******************************************\n");
printf(" ** 欢迎使用小学生测验系统 **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** 1.注册 **\n");
printf(" ** **\n");
printf(" ** 2.登录 **\n");
printf(" ** **\n");
printf(" ** 0.退出 **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ** **\n");
printf(" ******************************************\n");
printf(" 请选择功能编号:");
scanf("%d",&id);
switch(id)
{
case 1:regist();break;
case 2:
if(judgereg()==1)
dl();
break;
case 0:exit(1);system("pause");break;
default:
printf("\n 您输入的功能编号有误,请重新输入!\n");
system("pause");
}
}
}
int main(void)
{
srand(time(NULL));
system("color F4");
start();
system("cls");
menu();
int i;
if(switch1()!=2)
{
test();
for(i=1;i<=2;i++)
{
again1();
if(again2()==2)
{
system("cls");
break;
}
else
{
system("cls");
test();
}
}
}
printf(" 考试结束。\n");
system("pause");
return 0;
}