当前位置:网站首页>Comprehensive ability evaluation system
Comprehensive ability evaluation system
2022-07-06 04:04:00 【Try your best】
Purpose
Design and expand a comprehensive ability evaluation system . The system can realize menu selection self-test mode 、 Game mode 、 Difficulty and number of questions , In Canada 、 reduce 、 ride 、 In addition to the test module to achieve integration 、 Tips for correct and wrong questions 、 Wrong question set collection function , Realize scoring and ranking function in phased test , Through the game module to achieve entertainment functions .
Operation result diagram
Function is introduced
The comprehensive ability evaluation system is a system for primary school students to test the operation ability of addition, subtraction, multiplication and division
1. User rights guarantee
First, choose login or registration through the character interface , Then choose teachers or students . Then jump to the login or registration interface , Enter a name 、 Student ID and password . Login screen . If the program cannot retrieve the target account whose name and student number match the local file , Then return an error message and prompt that your account does not exist , Login interface if the program retrieves the target account whose name and student number match the local file, but the password does not match , Then return an error message and prompt that your password is incorrect .
2. Choose a test
In the main menu, select addition, subtraction, multiplication and division or comprehensive random test according to the prompt of the character interface and the corresponding keyboard input , Then choose the number and difficulty of questions one by one , The program will automatically generate the corresponding difficulty and number of questions for students , And show the student after the student saves it ( she ) Scores and the number of correct questions .
3. Ranking and error checking
In the periodic test , The program will give students points according to the difficulty and correctness of the questions. Students will update the accumulated points for each question they complete in the test , And after the students save the test results, update the total points for students to rank , Both students and teachers can check the ranking and wrong questions ( The wrong question set only records the addition, subtraction, multiplication and division modules Wrong question ).
The expanded functions of this group include : Set up a simple 、 Ordinary and difficult three kinds of difficulty , The integration method is reasonably arranged with the difficulty , Avoid blindly brushing points ; Wrong record , The set of wrong questions and the number of wrong questions are better consolidated and improved ; User evaluation , Give encouragement and suggestions in time ; There is ranking incentive effect .
Specific code
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <io.h>
#include <Windows.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include<stdio.h>
#include<conio.h>
#include<mmsystem.h>
#pragma comment(lib,"Winmm.lib")
#define DATALEN 100
using namespace std;
typedef struct man {
char id[10];
char name[8];
char pwd[12];
char sort;
char power;
int score;
}MAN;
struct wordUnit{
char id[10];
char name[8];
char pwd[12];
char sort;
char power;
int score;
};
int menu_first();
int login(char *sort_login);
int Register();
MAN ergodic(FILE* fp);// Traverse file functions
void Add(char sort_);
void Sub(char sort_);
void Mul(char sort_);
void Div(char sort_);
void result(int m,int s,int a,int b,char sort_r,char sign);
void AandS(int nandu,int cn,int cnt);
void MandD(int nandu,int cn,int cnt);
void WQ_set(char sort_);// Error set display function
void Menu(); // Menu interface
void Inform();// Explain the function
void Free();// Phase testing
void Eva();// Evaluation function
void MMul();
int Mul1();
int Mul2();
int Mul3();
void DDiv();
int Div1();
int Div2();
int Div3();
void AAdd();
void score_change(char sort_,int nscore);// Points saved
void Func();// ranking
int an,a,b,m,s,n,temp,nandu,cnt=0,cn=0,sum=0,ret=0,score=0,w;
char sort_=-1;
float k=0.0,l=0.0;
int main()
{
int judge=0;
int choose = 0;
//fflush(stdin);// Empty buffer
choose = menu_first();
if (choose == 1) // Sign in
{
while (!judge)
{
judge = login(&sort_);
}
}
else// register
{
while (!judge)
{
judge = Register();
}
judge = 0;
while (!judge)
{
judge = login(&sort_);
}
}
Menu();
bool flag=TRUE;
while(flag)
{
Menu();
}
return 0;
}
// Login function
int login(char *sort_login)
{
FILE* fp;
MAN x,input;
int judge = 0,judge2=0;
// Enter the login account information
printf("\n\n");
printf_s("%s\n", "\t\t\t\t Welcome to the login interface (* ^-^ *///):");
printf_s("%s", "\t\t\t\t\t Please enter the student number :");
scanf("%s", input.id);
printf_s("%s", "\t\t\t\t\t Please enter a name :");
scanf("%s", input.name);
printf_s("%s", "\t\t\t\t\t Please input a password :");
scanf("%s", input.pwd);
fopen_s(&fp, "accout.txt", "r+");
if (fp == NULL)
{
printf(" fail to open file ");
return 0;
}
// Loop through file functions
while ( !judge2||!feof(fp) )
{
judge2=1;
x = ergodic(fp);
if (strcmp(x.id, input.id) == 0 &&
strcmp(x.name, input.name) == 0 &&
strcmp(x.pwd, input.pwd) == 0
)
{
judge = 1;
printf_s("\t\t\t\t\t%s\n", " Login successful , Hello !(///^-^///)");
break;
}
}
fclose(fp);
if (judge == 0)// When the account does not exist or there is an error in input
{
printf_s("\t\t\t\t\t%s\n", " Input error , Is it a mistake ?");
system("pause");
Sleep(1000);
system("cls");
return 0;
}
else// When the target account is found and mapped one by one
{
*sort_login=x.sort;
system("pause");
Sleep(1000);
system("cls");
return 1;
}
//return 0;
}
// Register function
int Register()
{
FILE *fp=NULL,*fp2=NULL;
MAN s;
char test1[10], test2[10],test3[20];
fopen_s(&fp,"accout.txt", "a+");
if (fp == NULL)
{
printf_s("%s\n", "\t\t\t\t\tACCOUNT file does not exist !");
return 0;
}
printf_s("\n%s", "\t\t\t\t\t Are you a student or a teacher ?( teacher :T/ Student :S):");
scanf("%c", &s.power);
if (s.power != 'T' && s.power != 'S')// t or Error prompt for permission input
{
printf_s("%s\n", "\t\t\t\t\t Input error, please try again !");
system("pause");
system("cls");
fclose(fp);
return 0;
}
// Input MAN Structure s
printf_s("%s","\t\t\t\t\t Please enter the student number :");
scanf("%s", s.id);
printf_s("%s", "\t\t\t\t\t Please enter a name :");
scanf("%s", s.name);
printf_s("%s", "\t\t\t\t\t Please input a password :");
scanf("%s", test1);
printf_s("%s", "\t\t\t\t\t Please enter the password again :");
scanf("%s",test2);
strcpy_s(s.pwd, test1);
fopen_s(&fp2, "sort.txt", "r");
s.sort = fgetc(fp2);// The serial number from char The switch to int
if (fp2 != NULL)
{
fclose(fp2);
}
// The password is the same , The registration is successful , If not, exit and try again
if (strcmp(test1, test2) == 0)// Registered successfully
{
printf_s("%s\n", "\t\t\t\t\t\t Registered successfully !");
fprintf(fp, "%s\t%s\t%s\t%c\t%c\t%c\n", s.id, s.name, s.pwd, s.sort,s.power,'0');
fopen_s(&fp2, "sort.txt", "r+");
if (fp2 != NULL)
{
fputc(s.sort + 1, fp2);
}
fclose(fp2);
// Create a mistake set file
if (s.power == 'S')
{
strcpy_s(test3, "MC");
strcpy_s(test2,"");
test2[0]=s.sort;
test2[1]='\0';
strcat(test3, test2);
strcat(test3, ".txt");
// printf_s("%s\n", test3);
creat( test3, 00700);// The user group that created the file is readable 、 Write 、 perform
}
system("pause");
system("cls");
fclose(fp);
return 1;
}
else // Registration failed
{
printf_s("%s\n", "\t\t\t\t\t\t The password entered before and after is incorrect !");
system("pause");
system("cls");
fclose(fp);
return 0;
}
}
// Initial menu
int menu_first()
{
int choose;
printf_s("\t\t\t%s\n", "---------------------------------");
printf_s("\t\t\t%s\n", "| Do you want to login or register a new account ? |");
printf_s("\t\t\t%s\n", "| Please press 1, To register, please press 0:(*^-^*)|");
printf_s("\t\t\t%s\n", "---------------------------------");
printf_s("\t\t\t choice :");
scanf("%d", &choose);
getchar();
system("pause");
system("cls");
return choose;
}
// Traverse file functions
MAN ergodic(FILE* fp)
{
MAN x = {
" "," "," ",'0','0' ,0};
fscanf(fp,"%s\t%s\t%s\t%c\t%c\t%d\n",x.id,x.name,x.pwd,&x.sort,&x.power,&x.score);
return x;
}
void Menu() // Menu interface
{
int xuan;
printf("\t\t Children , Welcome to learn arithmetic in primary school !* * * * * * * * * * \n");
printf("\t\t Choose your learning content quickly !! * * * * * * * * * * ⌒_⌒\n");
printf("\n");
printf("\t\t\t\t\t\t\t The main menu \n") ;
printf("\t\t ╔══════════════════════════════════════════════════════════════════════════════════════════╗\n");
printf("\t\t ║ 1. Add 2. Subtraction 3. Multiplication 4. division ║\n");
printf("\t\t ║-------------------------------------------------------------------------------- ║\n") ;
printf("\t\t ║ 5. explain 6. evaluation 7. Phase testing 8. ranking ║\n") ;
printf("\t\t ║-------------------------------------------------------------------------------- ║\n") ;
printf("\t\t ║ 9. Multiplication game 10. Division game 11. Addition comparison game 12. Set of wrong questions ║\n") ;
printf("\t\t ╚══════════════════════════════════════════════════════════════════════════════════════════╝\n");
printf("\n");
printf("\n");
printf("\t\t The rule of points :\n");
printf("\t\t ╔════════════════════════════════════════════════════════════════════════════╗\n");
printf("\t\t ║ ║ 1. Add 2. Subtraction 3. Multiplication 4. division ║\n");
printf("\t\t ║——————║——————————————————————————————— ║\n");
printf("\t\t ║ error ║ -1 -1 -1 -1 ║\n");
printf("\t\t ║ Correct and simple ║ 1 1 2 2 ║\n");
printf("\t\t ║ Correct and common ║ 2 2 3 3 ║\n");
printf("\t\t ║ Correct and difficult ║ 3 3 4 4 ║\n");
printf("\t\t ╚════════════════════════════════════════════════════════════════════════════╝\n");
printf("\n");
printf(" To exit, please select :0\n");
printf("\n\t\t My choice :");
scanf("%d",&xuan) ;
system("cls");
switch(xuan)
{
case 0:exit(1);
break;
case 1:Add(sort_);
break;
case 2:Sub(sort_);
break;
case 3:Mul(sort_);
break;
case 4:Div(sort_);
break;
case 5:Inform();
break;
case 6:Eva();
break;
case 7:Free();
break;
case 8:Func();
break;
case 9:MMul();
break;
case 10:DDiv();
break;
case 11:AAdd();
break;
case 12:WQ_set(sort_);// The test serial number is sort_ Display of the wrong question set of the account
break;
}
}
void Add(char sort_) // Addition interface Parameter table ( The serial number of the logged in account )
{
float start,end;
srand(time(0));
cnt=0;
cn=0;
printf(" Children , Enter the addition test quickly !\n\n");
printf(" Please choose the difficulty of the topic :1. Simple 2. Ordinary 3. difficult \n");
scanf("%d",&nandu);
printf(" Please input the number of questions :");
scanf("%d",&n);
start=clock();
for(int i=1;i<=n;i++)
{
if(nandu==1)
{
a=rand()%10;
b=rand()%10;
}
else if(nandu==2)
{
a=rand()%100;
b=rand()%100;
}
else
{
a=rand()%1000;
b=rand()%1000;
}
printf(" The first %d topic :",i);
printf("%d+%d= \n",a,b);
m=a+b;
printf(" Please enter your calculation results :");
scanf("%d",&s);
result(m,s,a,b,sort_,'+');// Call the function to judge the correct answer
}
end=clock();
AandS(nandu,cn,cnt);// Call the calculation accuracy and scoring function
printf(" when :%.1f second \n",(float)(end-start)*0.001);
system("pause");
system("cls");
}
void Sub(char sort_)// Subtraction interface Parameter table ( The serial number of the logged in account )
{
int start,end;
srand(time(0));
cnt=0;
cn=0;
printf(" Children , Enter the subtraction test quickly !\n\n");
printf(" Please choose the difficulty of the topic :1. Simple 2. Ordinary 3. difficult \n");
scanf("%d",&nandu);
printf(" Please input the number of questions :");
scanf("%d",&n);
start=clock();
for(int i=1;i<=n;i++)
{
if(nandu==1)
{
a=rand()%10;
b=rand()%10;
}
else if(nandu==2)
{
a=rand()%100;
b=rand()%100;
}
else
{
a=rand()%1000;
b=rand()%1000;
}
printf(" The first %d topic :",i);
printf("%d-%d= \n",a,b);
m=a-b;
printf(" Please enter your calculation results :");
scanf("%d",&s);
result(m,s,a,b,sort_,'-');// Call the function to judge the correct answer
}
end=clock();
AandS(nandu,cn,cnt);// Call the calculation accuracy and scoring function
printf(" when :%.1f second \n",(float)(end-start)*0.001);
system("pause");
system("cls");
}
void Mul(char sort_) // Multiplication function Parameter table ( The serial number of the logged in account )
{
int start,end;
srand(time(0));
int a,b,m,s,n,nandu;
cnt=0;
cn=0;
printf(" Children , Hurry to the multiplication test !\n\n");
printf(" Please choose the difficulty of the topic :1. Simple 2. Ordinary 3. difficult \n");
scanf("%d",&nandu);
printf(" Please input the number of questions :");
scanf("%d",&n);
start=clock();
for(int i=1;i<=n;i++)
{
if(nandu==1)
{
a=rand()%10;
b=rand()%10;
}
else if(nandu==2)
{
a=rand()%100;
b=rand()%100;
}
else
{
a=rand()%1000;
b=rand()%1000;
}
printf(" The first %d topic :",i);
printf("%d×%d= \n",a,b);
m=a*b;
printf(" Please enter your calculation results :");
scanf("%d",&s);
result(m,s,a,b,sort_,'*');// Call the function to judge the correct answer
}
end=clock();
MandD(nandu,cn,cnt);// Call the calculation accuracy and scoring function
printf(" when :%.1f second \n",(float)(end-start)*0.001);
system("pause");
system("cls");
}
void Div(char sort_)// Division function Parameter table ( The serial number of the logged in account )
{
int start,end;
srand(time(0));
cnt=0;
cn=0;
printf(" Children , Enter the division test quickly !\n\n");
printf(" Please choose the difficulty of the topic :1. Simple 2. Ordinary 3. difficult \n");
scanf("%d",&nandu);
printf(" Please input the number of questions < It is suggested that 20 The number of passes is about >:");
scanf("%d",&n);
start=clock();
for(int i=1;i<=n;i++)
{
if(nandu==1)
{
a=rand()%10;
b=rand()%10;
}
else if(nandu==2)
{
a=rand()%100;
b=rand()%100;
}
else
{
a=rand()%1000;
b=rand()%1000;
}
printf(" The first %d topic :",i);
printf("%d÷%d= \n",a,b);
l=1.0*a/b;
printf(" Please enter your calculation results :");
scanf("%f",&k);
result(l,k,a,b,sort_,'/');// Call the function to judge the correct answer
}
end=clock();
MandD(nandu,cn,cnt);// Call the calculation accuracy and scoring function
printf(" when :%.1f second \n",(float)(end-start)*0.001);
system("pause");
system("cls");
}
void Inform()// Explain the function
{
printf(" Description of the system \n\n\n");
printf(" This project is an application C Language development of primary school students' arithmetic self-test system , The system can provide function selection through menu , Be able to achieve simple \n Add , Subtraction , Multiplication and division Random test of ( The addition and subtraction method adopts the scoring system , It's going on many times \n After the addition and subtraction test, they can also be ranked from low to high by addition and subtraction , And output the highest score \n And the lowest score , The multiplication and division method adopts the customs clearance mode ), Can realize the selection of question quantity , Title Review , Answer tips , Evaluation and other functions .\n");
printf(" 1: The addition and subtraction method adopts the timing and scoring mode , It judges according to the range of scores ABCD Four levels , Then every time you run the program \n The results of the addition and subtraction operations are stored separately , Finally, you can view it in the menu interface , Own score ranking and \n Your highest and lowest scores .\n");
printf(" 2: The multiplication and division method adopts the breakthrough mode , The first level is that both operands are single digits ; The first operand of the second level is a single digit , The second fuck \n Counting is in double digits ; Third, both operands are two digits ; If the result of division is an integer 3 perhaps \n Rational number 2.75, Get the result directly , If it is an irrational number , Keep two decimal places ( rounding )5.6666... Output 5.67. ");
printf("\n");
printf("\n\n\n");
system("pause");
system("cls");
}
void Eva()// Evaluation function
{
int eva;
printf(" How satisfied are you with our system ?\n");
printf(" Please rate us (0--10 branch ):") ;
scanf("%d",&eva);
if(eva>=0&&eva<=5)
{
printf(" Thanks for your participation. ! We will try our best to improve !\n");
}
else if(eva>=6&&eva<=10)
{
printf(" Thank you for your encouragement ! We will continue to refuel !\n");
}
system("pause");
system("cls");
}
void result(int m,int s,int a,int b,char sort_r,char sign)// Judge whether the calculation input answer is correct
{
FILE *fp=NULL;
char test3[20],test2[20];
strcpy_s(test3, "MC");
strcpy_s(test2,"");
test2[0]=sort_r;
test2[1]='\0';
strcat(test3, test2);
strcat(test3, ".txt");
if(m==s)
{
printf(" Congratulations, you're right !\n");
printf("\n");
cnt++;// Number of correct questions
}
else
{
printf(" I'm sorry you got the wrong answer ! The correct answer should be %d\n",m);
printf("\n");
cn++; //cw
fp=fopen(test3,"a");
if(fp==NULL)
{
printf(" The file is empty \n");
}
fprintf_s(fp,"%d %c %d = %d The right answer is : %d\n",a,sign,b,s,m);
fclose(fp);
}
return ;
}
void AandS(int nandu,int cn,int cnt) // Calculate the integral operation of addition and subtraction ,n Is to input the number of questions ,cnt Is the number of correct answers
{
printf("\n\n You got the answer right %d topic \n",cnt);
printf("\n You answered wrong %d topic \n",cn);
ret=cnt*nandu-cn;
printf("\n This time, I got %d branch \n",ret);
}
void MandD(int nandu,int cn,int cnt) // Calculate the integral operation of multiplication and division
{
printf("\n\n You got the answer right %d topic \n",cnt);
printf("\n You answered wrong %d topic \n",cn);
int score;
score=cnt*(nandu+1)-cn;
printf("\n This time, I got %d branch \n",score);
}
void WQ_set(char sort_)// Error set display function Parameter table ( The serial number of the logged in account )
{
FILE *fp=NULL,*fpx=NULL;
char test3[20],test2[20],test[30];
MAN x;
strcpy_s(test3, "MC");
strcpy_s(test2,"");
test2[0]=sort_;
test2[1]='\0';
strcat(test3, test2);
strcat(test3, ".txt");
fpx=fopen("accout.txt","r");
while ( !feof(fp) )
{
x = ergodic(fpx);
if (x.sort==sort_)
{
printf(" Student number :%s full name :%s Wrong question set \n ",x.id,x.name);
break;
}
}
fp=fopen(test3,"r");
while(!feof(fp))
{
fgets(test,30,fp);
printf("%s\n",test);
strcpy(test,"");
}
system("pause");
system("cls");
return ;
}
void Free()// Phase testing
{
int start,end;
srand(time(0));
int a,b,m,s,n,x,add=0,sub=0,mul=0,div=0,ad=0,su=0,mu=0,di=0;
printf(" Hurry to the test !\n\n");
printf(" There are two major questions in this test , common 100 branch .\n\n");
n=80;
start=clock();
for(int i=1;i<=n;i++)
{
x=rand()%4;
if(i>0&&i<=60)
{
if(i==1)
printf("( One ) This topic altogether 60 topic , Every little question 1 branch , common 60 branch .\n");
printf(" The first %d topic : ",i);
a=rand()%100;
b=rand()%100+1;
if(x==0)
{
printf("%d+%d= \n",a,b);
m=a+b;
printf(" Please enter your calculation results :");
scanf("%d",&s);
if(m==s)
{
printf(" Congratulations, you're right !\n");
printf("\n");
add++;
}
else
{
printf(" I'm sorry you got the wrong answer ! The correct answer should be %d\n",m);
printf("\n");
}
}
else if(x==1)
{
printf("%d-%d= \n",a,b);
m=a-b;
printf(" Please enter your calculation results :");
scanf("%d",&s);
if(m==s)
{
printf(" Congratulations, you're right !\n");
printf("\n");
sub++;
}
else
{
printf(" I'm sorry you got the wrong answer ! The correct answer should be %d\n",m);
printf("\n");
}
}
else if(x==2)
{
printf("%d*%d= \n",a,b);
m=a*b;
printf(" Please enter your calculation results :");
scanf("%d",&s);
if(m==s)
{
printf(" Congratulations, you're right !\n");
printf("\n");
mul++;
}
else
{
printf(" I'm sorry you got the wrong answer ! The correct answer should be %d\n",m);
printf("\n");
}
}
else
{
printf("%d/%d= \n",a,b);
m=a/b;
printf(" Please enter your calculation results :");
scanf("%f",&k);
if(m==k)
{
printf(" Congratulations, you're right !\n");
printf("\n");
div++;
}
else
{
printf(" I'm sorry you got the wrong answer ! The correct answer should be %d\n",m);
printf("\n");
}
}
}
else if(i>60&&i<=80)
{
if(i==61)
printf("( Two ) This topic altogether 20 topic , Every little question 2 branch , common 40 branch .\n");
printf(" The first %d topic : ",i-60);
a=rand()%1000;
b=rand()%1000+1;
if(x==0)
{
printf("%d+%d= \n",a,b);
m=a+b;
printf(" Please enter your calculation results :");
scanf("%d",&s);
if(m==s)
{
printf(" Congratulations, you're right !\n");
printf("\n");
ad++;
}
else
{
printf(" I'm sorry you got the wrong answer ! The correct answer should be %d\n",m);
printf("\n");
}
}
else if(x==1)
{
printf("%d-%d= \n",a,b);
m=a-b;
printf(" Please enter your calculation results :");
scanf("%d",&s);
if(m==s)
{
printf(" Congratulations, you're right !\n");
printf("\n");
su++;
}
else
{
printf(" I'm sorry you got the wrong answer ! The correct answer should be %d\n",m);
printf("\n");
}
}
else if(x==2)
{
printf("%d*%d= \n",a,b);
m=a*b;
printf(" Please enter your calculation results :");
scanf("%d",&s);
if(m==s)
{
printf(" Congratulations, you're right !\n");
printf("\n");
mu++;
}
else
{
printf(" I'm sorry you got the wrong answer ! The correct answer should be %d\n",m);
printf("\n");
}
}
else
{
printf("%d/%d= \n",a,b);
m=a/b;
printf(" Please enter your calculation results :");
scanf("%f",&k);
if(m==s)
{
printf(" Congratulations, you're right !\n");
printf("\n");
di++;
}
else
{
printf(" I'm sorry you got the wrong answer ! The correct answer should be %d\n",m);
printf("\n");
}
}
}
}
s=(add+sub+mul+div)*1+(ad+su+mu+di)*2;
printf(" Your score is :%d\n",s);
score_change(sort_,s);
printf(" If you want to know the ranking , Please select 1, Otherwise select 0\n");
printf(" Please select :");
scanf("%d",&w);
if(w==1)
{
Func();
}
end=clock();
printf("\n");
printf(" when :%.1f second \n",(float)(end-start)*0.001);
system("pause");
system("cls");
}
void MMul() // Multiplication function
{
int f1,f2,f3;
do
{
f1=Mul1();
}while(f1==1);
if(f1==2)
{
do
{
f2=Mul2();
}while(f2==1);
if(f2==2)
{
do
{
f3=Mul3();
}while(f3==1);
system("pause");
system("cls");
Menu();
}
else
{
system("cls");
Menu();
}
}
else
{
system("cls");
Menu();
}
}
int Mul1() // Multiplication game
{
int count=0,n,answer,a,b,find=1;
char ch;
srand(time(NULL));
printf(" Hurry to the multiplication test !\n\n");
printf(" Welcome to the first level !\n");
printf(" Please set the number of questions :");
scanf("%d",&n);
do
{
answer=0;
a=rand()%10;
b=rand()%10;
printf("%d*%d=",a,b);
scanf("%d",&answer);
if (answer==(a*b))
printf(" bingo !\n");
else
{
printf(" unfortunately , Wrong answer !\n");
find=0;
}
count++;
}while(count<n);
if (find==0)
{
printf(" unfortunately , Failed to pass the first level !\n");
printf(" Whether to continue to challenge ?Y<1>/N<0>:");
scanf(" %c",&ch);
if (ch=='Y'||ch=='1')
return 1;
else
return 0;
}
else
{
printf(" Congratulations on passing the first level !\n");
printf(" Whether to continue to challenge ?Y<1>/N<0>:");
scanf(" %c",&ch);
if (ch=='Y'||ch=='1')
return 2;
else
return 0;
}
}
int Mul2()
{
int count=0,n,answer,a,b,find=1;
char ch;
srand(time(NULL));
printf(" Welcome to the second level !\n");
printf(" Please set the number of questions :");
scanf("%d",&n);
do
{
answer=0;
a=rand()%10;
b=rand()%90+10;
printf("%d*%d=",a,b);
scanf("%d",&answer);
if (answer==(a*b))
printf(" congratulations , bingo !\n");
else
{
printf(" unfortunately , Wrong answer !\n");
find=0;
}
count++;
}while(count<n);
if (find==0)
{
printf(" unfortunately , Failed to pass the second level !\n");
printf(" Whether to continue to challenge ?Y<1>/N<0>:");
scanf(" %c",&ch);
if (ch=='Y'||ch=='1')
return 1;
else
return 0;
}
else
{
printf(" Congratulations on passing the second level !\n");
printf(" Whether to continue to challenge ?Y<1>/N<0>:");
scanf(" %c",&ch);
if (ch=='Y'||ch=='1')
return 2;
else
return 0;
}
}
int Mul3()
{
int count=0,n,answer,a,b,find=1;
char ch;
srand(time(NULL));
printf(" Welcome to the third level !\n");
printf(" Please set the number of questions :");
scanf("%d",&n);
do
{
answer=0;
a=rand()%90+10;
b=rand()%90+10;
printf("%d*%d=",a,b);
scanf("%d",&answer);
if (answer==(a*b))
printf(" bingo !\n");
else
{
printf(" unfortunately , Wrong answer !\n");
find=0;
}
count++;
}while(count<n);
if (find==0)
{
printf(" unfortunately , Failed to pass the third level !\n");
printf(" Whether to continue to challenge ?Y<1>/N<0>:");
scanf(" %c",&ch);
if (ch=='Y'||ch=='1')
return 1;
else
return 0;
}
else
{
printf(" Congratulations on passing the third level !\n");
printf(" Congratulations on your success !\n");
return 0;
}
}
void DDiv()// Division function
{
int f1,f2,f3;
do
{
f1=Div1();
}while(f1==1);
if(f1==2)
{
do
{
f2=Div2();
}while(f2==1);
if(f2==2)
{
do
{
f3=Div3();
}while(f3==1);
system("pause");
system("cls");
Menu();
}
else
{
system("cls");
Menu();
}
}
else
{
system("cls");
Menu();
}
}
int Div1() // The game of division
{
int count=0,n,a,b,find=1;
char ch;
int answer;
srand(time(NULL));
printf(" Enter the division test quickly !\n\n");
printf(" Welcome to the first level !\n");
printf(" Please set the number of questions :");
scanf("%d",&n);
do
{
answer=0;
a=rand()%10;
b=rand()%9+1;
printf("%d/%d=",a,b);
scanf("%d",&answer);
if (answer==(a/b))
printf(" bingo !\n");
else
{
printf(" unfortunately , Wrong answer !\n");
find=0;
}
count++;
}while(count<n);
if (find==0)
{
printf(" unfortunately , Failed to pass the first level !\n");
printf(" Whether to continue to challenge ?Y<1>/N<0>:");
scanf(" %c",&ch);
if (ch=='Y'||ch=='1')
return 1;
else
return 0;
}
else
{
printf(" Congratulations on passing the first level !\n");
printf(" Whether to continue to challenge ?Y<1>/N<0>:");
scanf(" %c",&ch);
if (ch=='Y'||ch=='1')
return 2;
else
return 0;
}
}
int Div2()
{
int count=0,n,a,b,find=1;
char ch;
int answer;
srand(time(NULL));
printf(" Welcome to the second level !\n");
printf(" Please set the number of questions :");
scanf("%d",&n);
do
{
answer=0;
a=rand()%90+10;
b=rand()%9+1;
printf("%d/%d=",a,b);
scanf("%d",&answer);
if (answer==(a/b))
printf(" bingo !\n");
else
{
printf(" unfortunately , Wrong answer !\n");
find=0;
}
count++;
}while(count<n);
if (find==0)
{
printf(" unfortunately , Failed to pass the second level !\n");
printf(" Whether to continue to challenge ?Y<1>/N<0>:");
scanf(" %c",&ch);
if (ch=='Y'||ch=='1')
return 1;
else
return 0;
}
else
{
printf(" Congratulations on passing the second level !\n");
printf(" Whether to continue to challenge ?Y<1>/N<0>:");
scanf(" %c",&ch);
if (ch=='Y'||ch=='1')
return 2;
else
return 0;
}
}
int Div3()
{
int count=0,n,a,b,find=1;
char ch;
int answer;
srand(time(NULL));
printf(" Welcome to the third level !\n");
printf(" Please set the number of questions :");
scanf("%d",&n);
do
{
answer=0;
a=rand()%90+10;
b=rand()%90+10;
printf("%d/%d=",a,b);
scanf("%d",&answer);
if (answer==(a/b))
printf(" bingo !\n");
else
{
printf(" unfortunately , Wrong answer !\n");
find=0;
}
count++;
}while(count<n);
if (find==0)
{
printf(" unfortunately , Failed to pass the third level !\n");
printf(" Whether to continue to challenge ?Y<1>/N<0>:");
scanf(" %c",&ch);
if (ch=='Y'||ch=='1')
return 1;
else
return 0;
}
else
{
printf(" Congratulations on passing the third level !\n");
printf(" Congratulations on your success !\n");
return 0;
}
}
void AAdd()// Addition comparison game
{
int a,b,c,d,i,j,y,ans1,ans2,count;
char ch;
srand(time(NULL));
printf(" The number of levels is 3\n");
printf(" requirement : Please set the number of questions for each level :\n");
scanf("%d",&y);
getchar();
printf(" requirement : Please be there. [] Input in > or < or = Establish \n");
for(i=1;i<=3;i++)
{
printf(" The first %d Turn off :\n",i);
count=0;
for(j=1;j<=y;j++)
{
if(i==1)
{
a=rand()%10;
b=rand()%10;
c=rand()%10;
d=rand()%10;
}
else if(i==2)
{
a=rand()%100;
b=rand()%100;
c=rand()%100;
d=rand()%100;
}
else
{
a=rand()%1000;
b=rand()%1000;
c=rand()%1000;
d=rand()%1000;
}
ans1=a+b;
ans2=c+d;
printf("%d+%d [] %d+%d\n",a,b,c,d);
printf(" Please enter > or < or = :");
scanf("%c",&ch);
getchar();
if(ch=='>')
{
if(ans1>ans2)
{
printf(" correct !\n");
count++;
}
else
{
printf(" error ! Failed to pass the pass !!\n");
Sleep(1500);
break;
}
}
else if(ch=='<')
{
if(ans1<ans2)
{
printf(" correct !\n");
count++;
}
else
{
printf(" error ! Failed to pass the pass !!\n");
Sleep(1500);
break;
}
}
else if(ch=='=')
{
if(ans1==ans2)
{
printf(" correct !\n");
count++;
}
else
{
printf(" error ! Failed to pass the pass !!\n");
Sleep(1500);
break;
}
}
}
if(count==y)
{
printf(" Pass the level !\n\n");
Sleep(1500);
}
else
{
printf(" Will exit the game .");
Sleep(1500);
system("cls");
Menu();
break;
}
}
system("cls");
Menu();
}
void score_change(char sort_,int nscore)
{
FILE *fpo=NULL,*fpn=NULL;//fp_original At first fp_new A new file The file pointer
MAN x;
int judge=0;
fpo=fopen("accout.txt","r");
fpn=fopen("temp.txt","w");
if(fpo==NULL||fpn==NULL)
{
printf(" File opening failure .");
return ;
}
while ( !judge||!feof(fpo) )
{
judge=1;
x = ergodic(fpo);
if (sort_==x.sort)
{
fprintf(fpn,"%s\t%s\t%s\t%c\t%c\t%d\n",x.id,x.name,x.pwd,x.sort,x.power,nscore);
}
else
{
fprintf(fpn,"%s\t%s\t%s\t%c\t%c\t%d\n",x.id,x.name,x.pwd,x.sort,x.power,x.score);
}
}
fclose(fpo);
fclose(fpn);
system("del accout.txt");
system("rename temp.txt accout.txt");
return ;
}
void Func(){
FILE *data;// File pointer to read
int i=0,j,k,m;// Structure questions array move
struct wordUnit words[DATALEN];
struct wordUnit t;
if((data=fopen("accout.txt","r"))==NULL){
printf("Can not open file\n");
exit(0);
}
while(!feof(data)){
// primary txt The data of the document is separated by spaces
fscanf(data,"%s\t%s\t%s\t%c\t%c\t%d\n",words[i].id,words[i].name,words[i].pwd,&words[i].sort,&words[i].power,&words[i].score);
i++;
}
fclose(data);
for(k=0;k<i;k++)// Outer layer for loop
{
for(j=0;j<i-k-1;j++)// Inner layer for loop
{
if(words[j].score < words[j+1].score)// Pick out the ones with high scores
{
t=words[j];
words[j]=words[j+1];
words[j+1]=t;
}
}
}
printf("\n");
printf("———————————————————— total row name ————————————————————————\n\n");
for(int j=0;j<i;j++){
printf("%-10s %-13s %-4d\n",words[j].id,words[j].name,words[j].score);
}
system("pause");
system("cls");
return ;
}
The above is a project completed during the training , Gain a lot , Although there are some imperfections , But it still makes me very satisfied .
边栏推荐
- 【leetcode】1189. Maximum number of "balloons"
- 登录mysql输入密码时报错,ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO/YES
- [meisai] meisai thesis reference template
- 【FPGA教程案例11】基于vivado核的除法器设计与实现
- Ks008 SSM based press release system
- 2/12 didn't learn anything
- ESP32(基于Arduino)连接EMQX的Mqtt服务器上传信息与命令控制
- Database, relational database and NoSQL non relational database
- Thread sleep, thread sleep application scenarios
- [prediction model] difference method model
猜你喜欢
Chinese brand hybrid technology: there is no best technical route, only better products
IDEA编译JSP页面生成的class文件路径
Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
Stack and queue
SSTI template injection explanation and real problem practice
阿里测试师用UI自动化测试实现元素定位
如何修改表中的字段约束条件(类型,default, null等)
Security xxE vulnerability recurrence (XXe Lab)
Exchange bottles (graph theory + thinking)
Alibaba testers use UI automated testing to achieve element positioning
随机推荐
/usr/bin/gzip: 1: ELF: not found/usr/bin/gzip: 3: : not found/usr/bin/gzip: 4: Syntax error:
MySql數據庫root賬戶無法遠程登陸解决辦法
[FPGA tutorial case 12] design and implementation of complex multiplier based on vivado core
Yyds dry goods inventory hcie security Day11: preliminary study of firewall dual machine hot standby and vgmp concepts
综合能力测评系统
【leetcode】1189. Maximum number of "balloons"
Determine which week of the month the day is
20、 EEPROM memory (AT24C02) (similar to AD)
ESP32(基于Arduino)连接EMQX的Mqtt服务器上传信息与命令控制
C (thirty) C combobox listview TreeView
Do you know cookies, sessions, tokens?
C mouse event and keyboard event of C (XXVIII)
[Massey] Massey font format and typesetting requirements
About some basic DP -- those things about coins (the basic introduction of DP)
Record an excel xxE vulnerability
DM8 backup set deletion
Alibaba testers use UI automated testing to achieve element positioning
51nod 1130 n factorial length V2 (Stirling approximation)
Blue Bridge Cup - day of week
潘多拉 IOT 开发板学习(HAL 库)—— 实验9 PWM输出实验(学习笔记)