master
18570281412 7 years ago
parent 69a1332dde
commit d3e580423b

@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <windows.h>
#include "BOOKUI.h"
#include "user.h"
int main()
{
HideCursor();
choice = 0;
setcolor(11,0);
Settitle("|学生选课系统|");
system("mode con cols=180 lines=50");
player();
system("mode con cols=105 lines=30");
showtitle();
HideCursor();
login1();//登录或注册的选择界面(进入程序的第一步)
return 0;
}

@ -0,0 +1 @@
18408000921 123123 001 o o 1

169
user.c

@ -0,0 +1,169 @@
#include "user.h"
#include "BOOKUI.h"
#include "login.h"
#include <string.h>
int login1()
{
system("cls");
HideCursor();
showtitle();
while(1)
{
welcome();
HideCursor();
char a,b;
b = getch();
if(b==-32)
a = getch();
fflush(stdin);
if(a == UP && b == -32)
{
choice--;
}
else if(a == DOWN && b == -32)
{
choice++;
}
else if(b==13){
login2(choice);
break;
}
else{
setposition(19,12);
printf("输入“↑”或“↓”,回车键确认");
}
if(choice<0) choice = 1;
if(choice>1) choice = 0;
}
return 0;
}
int login2(int k)
{
//k==0为登陆
if(k == 0)
{
Settitle("|学生选课系统|登陆界面|");
while(1)
{
comuser(choice);
HideCursor();
char a,b;
b = getch();
if(b == -32)
a = getch();
fflush(stdin);
if(a == UP && b == -32)
{
choice--;
}
else if(a == DOWN && b == -32)
{
choice++;
}
else if(b==13){
login3(choice);
break;
}
else{
setposition(LB,12);
printf("输入“↑”或“↓”,回车键确认");
}
if(choice<0) choice = 1;
if(choice>1) choice = 0;
}
return 0;
}
//k==1为注册
if(k == 1)
{
regist();
}
return 0;
}
void login3(int k)
{
//k==0表示普通用户登陆
if(k==0)
{
Settitle("|学生选课系统|登陆界面|普通用户登陆|");
loginuser();
}
//k==1表示管理员登陆
if(k==1)
{
Settitle("|学生选课系统|登陆界面|管理员登陆|");
int lim = 5;
while(lim--)
{
if(!admin())
{
Sleep(300);
setposition(LB,15);
printf("你还剩%d次机会\n",lim);
HideCursor();
Sleep(1000);
system("cls");
showtitle();
comuser(1);
setposition(LB,12);
HideCursor2();
}
else break;
}
}
}
int admin()
{
Settitle("|学生选课系统|管理员登陆|");
char adminpw[50];
char adminpwr[50];
system("cls");
showtitle();
comuser(1);
setposition(LB,12);
HideCursor2();
printf("请输入管理员账号:");
gets(ADMIN.id);
if((fp = fopen(ADMIN.id,"r"))==NULL)
{
system("cls");
printf("\n\n\t不存在该管理员!");
printf("\n\n\t3秒后退出程序\n");
Sleep(3000);
exit(0);
}
if(fgetc(fp)==EOF)
{
printf("\n\n\t不安全的管理员!");
printf("\n\n\t3秒后退出程序\n");
Sleep(3000);
exit(0);
}
rewind(fp);
fscanf(fp,"%s",adminpwr);
setposition(LB,13);
printf("请输入管理员密码:");
gets(adminpw);
rewind(fp);
setposition(LB,14);
if(strcmp(adminpw,adminpwr) == 0)
{
fscanf(fp,"%s%s%s%s%d",ADMIN.pass,ADMIN.book1,ADMIN.book2,ADMIN.book3,&ADMIN.booknum);
close();
admin_BOOK_choice();
return 1;
}
else if(strcmp(adminpw,adminpwr) != 0)
{
printf("密码错误");
close();
return 0;
}
return 0;
}

@ -0,0 +1,16 @@
#ifndef USER_H_INCLUDED
#define USER_H_INCLUDED
#include<conio.h>
#include "BOOKUI.h"
#include "admin.h"
#define UP 72
#define DOWN 80
#define RIGHT 77
#define LEFT 75
int admin();//管理员登陆
int login1(); //选择登陆或注册
int login2(int); //进行登陆类型选择
void login3(int); //进行登陆
#endif // USER_H_INCLUDED
Loading…
Cancel
Save