master
18570281412 7 years ago
commit a09513510b

1
123

@ -0,0 +1 @@
123 o o o 0

1174
BOOKS.c

File diff suppressed because it is too large Load Diff

@ -0,0 +1,65 @@
#ifndef BOOKS_H_INCLUDED
#define BOOKS_H_INCLUDED
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <windows.h>
#include "user.h"
#include "BOOKUI.h"
#include "login.h"
#include "admin.h"
//#define "轻小说" 0
//#define "教育" 1
//#define "文学" 2
//#define "科幻" 3
//#define "自然科学" 4
//#define "外国文学" 5
//#define "禁书" 6
char *temp[1000];
FILE *fp_BOOK;
typedef struct memer_BOOK{
char id[21]; //编号
char name[21]; //书名
char author[21]; //作者
char type[21]; //类型 --->选项 类
char publish[21]; //出版社
int num; //数量 --->录入时查重,完全重复才++
struct memer_BOOK *next;
}BOOK;
char book1[21],book2[21],book3[21];
int booknum;
int books();
void newone_BOOK();
int newok_BOOK(char*id,char*name,char*author,char*type,char*publish,int num);
void showall_BOOK(int peo);
void in_BOOK();
void close_BOOK();
void save_BOOK();
void mpsort_BOOK();
void book_function_info(int choice);//用户功能菜单
void book_function_choose();//用户功能菜单的实现
void book_type_menu_info(int choice);//书本的类型菜单
int book_type_menu_choose();//书本的类型菜单的实现
void new_info();
void alter_BOOK_info();
void alter_BOOK();
void del_BOOK_info();
void del_BOOK();
void exchange_BOOK(char*,char*);
void conshow_BOOK(int fun,int peo);
void conshow_BOOK_choice(int peo);//0为user 1为admin
void conshow_BOOK_menu(int choice);
void borrowandreturn_BOOK_choice(int peo);//0为user 1为admin
void borrowandreturn_BOOK_menu(int choice);
void borrowandreturn_BOOK_info();
void borrow_BOOK(int peo);
void return_BOOK(int peo);
void change_password();
void back_BOOK(int peo);
#endif // BOOKS_H_INCLUDED

@ -0,0 +1,118 @@
#include "BOOKUI.h"
char first[2][20] = {"登陆","注册"};
char login_uesr[2][20] = {"普通用户登陆","管理员登陆"};
void Settitle(char *title)//设置控制台标题
{
SetConsoleTitle(title);
}
void setcolor(int forecolor,int bgcolor)
{
HANDLE win = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(win,forecolor + bgcolor *0x10);
}
void setposition(int x,int y)
{
HANDLE win = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos = {x,y+3};
SetConsoleCursorPosition(win,pos);
}
void showtitle()//显示标题
{
setposition(LB,0);
printf("--------------------------------------------------------------");
setposition(LB,1);
printf("|");
setposition(LB+25,1);
printf("学生选课系统");
setposition(LB+61,1);
printf("|");
setposition(LB,2);
printf("--------------------------------------------------------------");
int i;
for(i = 0; i < 8;i++){
setposition(LB,START+i);
printf("|");
setposition(LB+61,START+i);
printf("|");
}
setposition(LB,START+i);
printf("--------------------------------------------------------------");
}
void welcome()
{
int i,j = 0,k=-1;
for(i = 0; i <= 1;i++,k++)
{
if(choice == i)
setcolor(0,15);
setposition(LB+28,START+i+k+3);
printf("%s",first[j++]);
setcolor(11,0);
}
}
void comuser(int t)//用户登陆类型选择
{
int i,j = 0,k=-1;
for(i = 0; i <= 1;i++,k++)
{
if(t == i)
setcolor(0,15);
setposition(LB+25,START+i+k+3);
printf("%s",login_uesr[j++]);
setcolor(11,0);
}
}
void HideCursor() //隐藏光标
{
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
void HideCursor2() //光标
{
CONSOLE_CURSOR_INFO cursor_info = {1, 1};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
void clean()
{
printf(" ");
}
void player()
{
FILE *aim;
if((aim=fopen("aim.txt","r"))==NULL)
{
return;
}
char page[70][220];
int i,hang=60;
while(!feof(aim))
{
Sleep(33);
HideCursor();
for(i = 0; i < hang;i++)
{
fgets(page[i],209,aim);
}
for(i = 10; i < hang-5; i++)
{
printf("%s",page[i]+10);
}
setposition(0,-3);
}
system("cls");
Sleep(500);
}

@ -0,0 +1,47 @@
#ifndef BOOKUI_H_INCLUDED
#define BOOKUI_H_INCLUDED
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "admin.h"
#define LB 19
#define START 3
#define INFO 12
int choice;
void player();
char first[2][20];
char login[2][20];
void position();
void Settitle(char *);//设置控制台标题
void HideCursor(); //隐藏光标
void HideCursor2(); //显示光标
/*
0 = 8 =
1 = 9 =
2 = 绿 10 = 绿
3 = 绿 11 = 绿
4 = 12 =
5 = 13 =
6 = 14 =
7 = 15 =
*/
void setcolor(int forecolor,int bgcolor);
void setposition(int x,int y);
void showtitle();//显示标题
void welcome();//欢迎界面以及登陆
void comuser(int);
void clean();//清除本行的数据
#endif // BOOKUI_H_INCLUDED

@ -0,0 +1,223 @@
#include "admin.h"
#include <string.h>
void admin_BOOK_menu(int choice)
{
system("cls");
showtitle();
Settitle("|学生选课系统|管理员功能菜单|");
in_BOOK();
char o[8][30] = {"浏 览 现 有 课 程 信 息","选 课 与 退 课","修 改 课 程 信 息","删 除 课 程","新 增 课 程","全部用户信息","修改用户密码","修改当前密码"};
int i,j = 0;
for(i = 0; i < 8;i++)
{
if(choice == i)
setcolor(0,15);
setposition(LB+21,START+i);
printf("%s",o[j++]);
setcolor(11,0);
}
if(choice == 8)
setcolor(0,15);
setposition(LB+50,START+i-1);
printf("退出登陆");
setcolor(11,0);
strcpy(book1,ADMIN.book1);
strcpy(book2,ADMIN.book2);
strcpy(book3,ADMIN.book3);
booknum = ADMIN.booknum;
if(strcmp(book1,"o") == 0) book1[0] = 0;
if(strcmp(book2,"o") == 0) book2[0] = 0;
if(strcmp(book3,"o") == 0) book3[0] = 0;
setposition(LB,INFO+1);
printf("已选课程:%s %s %s",book1,book2,book3);
setposition(LB,INFO+2);
printf("(%d/3)",ADMIN.booknum);
}
void admin_BOOK_choice()
{
system("cls");
showtitle();
int choice = 0;
while(1)
{
admin_BOOK_menu(choice);
setposition(19,12);
printf("输入“↑”、“↓”“←”“→”,回车键确认");
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(a == LEFT && b == -32 && choice == 8)
{
choice--;
}
else if(a == LEFT && b == -32 && choice != 8)
{
choice = 8;
}
else if(a == RIGHT && b == -32 && choice == 8)
{
choice = 7;
}
else if(a == RIGHT && b == -32 && choice != 8)
{
choice = 8;
}
else if(b==13)
{
in();
if(choice == 0) conshow_BOOK_choice(1);
if(choice == 1) borrowandreturn_BOOK_choice(1);
if(choice == 2) alter_BOOK();
if(choice == 3) del_BOOK();
if(choice == 4) newone_BOOK();
if(choice == 5) showall();
if(choice == 6) change_user_all();
if(choice == 7) change_admin_password();
if(choice == 8) login1();
break;
}
else{
setposition(19,12);
printf("输入“↑”或“↓”,回车键确认");
}
if(choice<0) choice = 8;
if(choice>8) choice = 0;
}
}
void admin_BOOK_info()
{
Settitle("|学生选课系统|管理员功能菜单|");
system("cls");
showtitle();
setposition(LB+5,START+1);
printf("管 理 员 功 能 提 示 ");
setposition(LB+5,START+2);
printf("输入所有信息长度超过20字符将自动省略超过部分");
setposition(LB+5,START+3);
printf("录入任何信息若包含空格将自动省略第一个空格及其后面部分");
setposition(LB+5,START+4);
printf("一次只能新增一门课,若要修改数量请使用修改功能");
setposition(LB+5,START+5);
printf("最多借三门课");
}
void admin_save()
{
if((FP_ADMIN = fopen(ADMIN.id,"w"))==NULL)
{
system("cls");
printf("\n\n\t未知错误");
system("pause");
exit(0);
}
fprintf(FP_ADMIN,"%s %s %s %s %d ",ADMIN.pass,ADMIN.book1,ADMIN.book2,ADMIN.book3,ADMIN.booknum);
if(fclose(FP_ADMIN))
{
system("cls");
printf("\n\t*————*");
printf("\n\t*未知错误*");
printf("\n\t*————*");
system("pause");
exit(0);
}
}
void change_admin_password()
{
admin_menu_info();
Settitle("|学生选课系统|管理员功能|修改管理员密码|");
setposition(LB,INFO);
printf("原密码:");
char pass[20];
fflush(stdin);
scanf("%s",pass);
fflush(stdin);
setposition(LB,INFO+1);
if(strcmp(pass,ADMIN.pass) == 0)
{
printf("输入新密码:");
scanf("%s",pass);
char apass[20];
setposition(LB,INFO+2);
printf("确认新密码:");
scanf("%s",apass);
setposition(LB,INFO+3);
if(strcmp(apass,pass) == 0)
{
strcpy(ADMIN.pass,pass);
printf("修改成功!");
}
else
{
printf("两次输入的密码不一致!");
}
}
else{
printf("原密码错误!");
}
admin_save();
admin_BOOK_choice();
}
void change_user_all()
{
admin_menu_info();
Settitle("|学生选课系统|管理员功能|修改用户密码|");
ID();
setposition(LB,INFO+3);
printf("输入新密码:");
char pass[20];
scanf("%s",pass);
if(strlen(pass) < 6)
{
setposition(LB,INFO+2+2);
printf("密码长度过短!");
setposition(LB,INFO+3+2);
system("pause");
admin_BOOK_choice();
}
char apass[20];
setposition(LB,INFO+2+2);
printf("确认新密码:");
scanf("%s",apass);
setposition(LB,INFO+3+2);
if(strcmp(apass,pass) == 0)
{
strcpy(change->pass,pass);
printf("修改成功!");
}
else
{
printf("两次输入的密码不一致!");
}
save();
admin_BOOK_choice();
}
void admin_menu_info()
{
Settitle("|学生选课系统|管理员功能菜单|修改功能|");
system("cls");
showtitle();
setposition(LB+5,START+1);
printf("管 理 员 修 改 功 能 提 示 ");
setposition(LB+5,START+2);
printf("输入所有信息长度超过20字符将自动省略超过部分");
setposition(LB+5,START+3);
printf("录入任何信息若包含空格将自动省略第一个空格及其后面部分");
setposition(LB+5,START+4);
printf("管理员密码不能为空用户密码不能少于6位");
}

@ -0,0 +1,29 @@
#ifndef ADMIN_H_INCLUDED
#define ADMIN_H_INCLUDED
#include "BOOKUI.h"
#include "user.h"
#include "BOOKS.h"
#include "login.h"
FILE *FP_ADMIN;
struct admins{
char id[20],pass[20];
char book1[20],book2[20],book3[20];
int booknum;
};
typedef struct admins ADMINS;
ADMINS ADMIN;
void admin_BOOK_menu(int choice);
void admin_BOOK_choice();
void admin_BOOK_info();
void admin_save();
void change_admin_password();
void change_user_all();
void admin_menu_info();
#endif // ADMIN_H_INCLUDED

5281
aim.txt

File diff suppressed because it is too large Load Diff

@ -0,0 +1 @@
123 o o o 0

File diff suppressed because it is too large Load Diff

Binary file not shown.

@ -0,0 +1 @@
001 C语言 27 自然科学 12 19 002 Python 30 自然科学 12 10 003 日语 20 语言类 5 40 字符串id 测试 27 策略 999 999

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

@ -0,0 +1,137 @@
# depslib dependency file v1.0
1544181177 source:c:\users\15096\documents\c\hud\booklib\bookui.c
"BOOKUI.h"
1544181176 c:\users\15096\documents\c\hud\booklib\bookui.h
<stdio.h>
<stdlib.h>
<windows.h>
"admin.h"
1544181177 source:c:\users\15096\documents\c\hud\booklib\main.c
<stdio.h>
<stdlib.h>
<string.h>
<conio.h>
<windows.h>
"BOOKUI.h"
"user.h"
1544181176 source:c:\users\15096\documents\c\hud\booklib\user.c
"user.h"
"BOOKUI.h"
"login.h"
<string.h>
1544106355 c:\users\15096\documents\c\hud\booklib\user.h
<conio.h>
"BOOKUI.h"
"admin.h"
1544181177 source:c:\users\15096\documents\c\hud\booklib\login.c
<stdio.h>
<stdlib.h>
<string.h>
<conio.h>
<windows.h>
"login.h"
1544101008 c:\users\15096\documents\c\hud\booklib\login.h
"BOOKUI.h"
"user.h"
<time.h>
"BOOKS.h"
"admin.h"
1544181291 source:c:\users\15096\documents\c\hud\booklib\books.c
"BOOKS.h"
1544104379 c:\users\15096\documents\c\hud\booklib\books.h
<stdio.h>
<stdlib.h>
<string.h>
<conio.h>
<windows.h>
"user.h"
"BOOKUI.h"
"login.h"
"admin.h"
1544106477 c:\users\15096\documents\c\hud\booklib\admin.h
"BOOKUI.h"
"user.h"
"BOOKS.h"
"login.h"
1544181176 source:c:\users\15096\documents\c\hud\booklib\admin.c
"admin.h"
<string.h>
1546846940 source:c:\users\15096\documents\c\hud\图书管理系统\booklib\admin.c
"admin.h"
<string.h>
1544106477 c:\users\15096\documents\c\hud\图书管理系统\booklib\admin.h
"BOOKUI.h"
"user.h"
"BOOKS.h"
"login.h"
1546850546 c:\users\15096\documents\c\hud\图书管理系统\booklib\bookui.h
<stdio.h>
<stdlib.h>
<windows.h>
"admin.h"
1544106355 c:\users\15096\documents\c\hud\图书管理系统\booklib\user.h
<conio.h>
"BOOKUI.h"
"admin.h"
1545410929 c:\users\15096\documents\c\hud\图书管理系统\booklib\books.h
<stdio.h>
<stdlib.h>
<string.h>
<conio.h>
<windows.h>
"user.h"
"BOOKUI.h"
"login.h"
"admin.h"
1544101008 c:\users\15096\documents\c\hud\图书管理系统\booklib\login.h
"BOOKUI.h"
"user.h"
<time.h>
"BOOKS.h"
"admin.h"
1546847405 source:c:\users\15096\documents\c\hud\图书管理系统\booklib\books.c
"BOOKS.h"
1546852018 source:c:\users\15096\documents\c\hud\图书管理系统\booklib\bookui.c
"BOOKUI.h"
1546847479 source:c:\users\15096\documents\c\hud\图书管理系统\booklib\login.c
<stdio.h>
<stdlib.h>
<string.h>
<conio.h>
<windows.h>
"login.h"
1546850608 source:c:\users\15096\documents\c\hud\图书管理系统\booklib\main.c
<stdio.h>
<stdlib.h>
<string.h>
<conio.h>
<windows.h>
"BOOKUI.h"
"user.h"
1546846467 source:c:\users\15096\documents\c\hud\图书管理系统\booklib\user.c
"user.h"
"BOOKUI.h"
"login.h"
<string.h>

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="login.c" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4829" topLine="164" />
</Cursor>
</File>
<File name="admin.c" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5892" topLine="0" />
</Cursor>
</File>
<File name="admin.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="398" topLine="1" />
</Cursor>
</File>
<File name="BOOKUI.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="682" topLine="0" />
</Cursor>
</File>
<File name="main.c" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="240" topLine="0" />
</Cursor>
</File>
<File name="user.c" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2655" topLine="141" />
</Cursor>
</File>
<File name="BOOKS.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="7884" topLine="255" />
</Cursor>
</File>
<File name="BOOKS.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1841" topLine="42" />
</Cursor>
</File>
<File name="user.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="315" topLine="0" />
</Cursor>
</File>
<File name="BOOKUI.c" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="187" topLine="0" />
</Cursor>
</File>
<File name="login.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="841" topLine="6" />
</Cursor>
</File>
</CodeBlocks_layout_file>

Binary file not shown.

@ -0,0 +1 @@
001 C语言 27 自然科学 12 19 002 Python 30 自然科学 12 10 003 日语 20 语言类 5 40 字符串id 测试 27 策略 999 999

@ -0,0 +1,472 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <windows.h>
#include "login.h"
me*head = NULL;
int loginuser()
{
HideCursor2();
system("cls");
showtitle();
logininfo();
in();
enter();
return 0;
}
int regist()
{
Settitle("|学生选课系统|注册界面|");
HideCursor2();
system("cls");
showtitle();
info();
in();
newone();
return 0;
}
void logininfo()
{
setposition(LB+5,START+1);
printf("欢 迎 使 用 学 生 选 课 系 统");
setposition(LB+5,START+2);
printf("作 为 普 通 用 户 您 可 以 使 用 如 下 功 能 ");
setposition(LB+5,START+3);
printf("1. 浏 览 现 有 全 部 课 程 信 息");
setposition(LB+5,START+4);
printf("2. 选 课 与 退 课");
setposition(LB+5,START+6);
printf("登 陆 后 方 可 使 用");
}
void info()
{
Settitle("|学生选课系统|登陆界面|用户注册|");
setposition(LB+5,START+1);
printf("注 册 要 求 ");
setposition(LB+5,START+2);
printf("注 册 用 户 名 为 学 号");
setposition(LB+5,START+3);
printf("学 号 唯 一 不 可 重 复");
setposition(LB+5,START+4);
printf("学 号 与 密 码 长 度 不 多 于 2 0 个 字 符");
setposition(LB+5,START+5);
printf("无 法 注 册 管 理 员");
setposition(LB+5,START+6);
printf("账号和密码不允许出现空格若出现将自动省略空格后面部分");
setposition(LB+5,START+7);
printf("密 码 长 度 不 小 于 6 位");
}
void enter()
{
char aid[20],apass[20];
char password[20];
int more;
while(1){
system("cls");
showtitle();
logininfo();
setposition(LB+5,INFO);
printf("学号:");
scanf("%s",aid);
fflush(stdin);
me *now = head;
if(now == NULL)
{
more = 0;
setposition(LB+5,INFO);
clean();
setposition(LB+5,INFO);
printf("无信息!");
login1();
}
else
{
more = 0;
while(now!=NULL)
{
if(strcmp(now->id,aid) == 0)
{
user = now;
more = 1;
strcpy(password,now->pass);
strcpy(book1,now->book1);
strcpy(book2,now->book2);
strcpy(book3,now->book3);
booknum=now->booknum;
break;
}
now = now->next;
}
setposition(LB+5,INFO+1);
if(more == 1)
{
printf("密码:");
scanf("%s",apass);
fflush(stdin);
setposition(LB+5,INFO+2);
if(strcmp(password,apass) == 0)
{
books();
Sleep(1000);
break;
}
else {
printf("学号或密码错误");
Sleep(2000);
login1();
}
}
else{
printf("账号不存在!");
Sleep(2000);
login1();
continue;
}
}
}
}
void newone()
{
int flag = 1,more = 0;
char aid[21],apass[21],bpass[21];
do{
while(1)
{
system("cls");
showtitle();
info();
setposition(LB,INFO);
printf("输入学号:");
fflush(stdin);
scanf("%s",aid);
fflush(stdin);
if(space(aid))
{
setposition(LB,INFO+1);
printf("学号非法");
Sleep(2000);
continue;
}
//查重功能
me *now = head;
if(now == NULL)
{
more = 0;
break;
}
else
{
more = 0;
while(now!=NULL)
{
if(strcmp(now->id,aid) == 0)
{
more = 1;
break;
}
now = now->next;
}
if(more == 1)
{
setposition(LB,INFO);
clean();
setposition(LB,INFO);
printf("学号重复!");
Sleep(2000);
}
else if(strlen(aid)>20)
{
setposition(LB,INFO);
clean();
setposition(LB,INFO);
printf("学号过长!");
Sleep(2000);
continue;
}
else break;
}
}
//查重功能
setposition(LB,INFO+1);
printf("请输入密码:");
gets(apass);
if(space(apass))
{
setposition(LB,INFO+2);
printf("密码非法");
Sleep(2000);
continue;
}
else if(strlen(apass) > 20 || strlen(apass) < 6)
{
setposition(LB,INFO+1);
clean();
setposition(LB,INFO);
printf("密码长度不合法!");
Sleep(2000);
continue;
}
setposition(LB,INFO+2);
printf("确认你的密码:");
gets(bpass);
if(strcmp(apass,bpass) == 0) flag = 0;
else {
setposition(LB,INFO+3);
printf("两次密码输入不一致!");
Sleep(1000);
continue;
}
if(AI()){
setposition(LB,INFO+5);
printf("验证码错误!");
flag = 1;
Sleep(1000);
continue;
}
}while(flag);
setposition(LB,INFO+5);
HideCursor();
if(newok(aid,apass,"o","o","o",0))
{
printf("注册成功!");
Settitle("|学生选课系统|注册成功|");
int cnt = 0,cnt2;
for(cnt2 = 0; cnt2 < 3; cnt2++)
{
setposition(LB+10,INFO+5);
printf(" ");
Sleep(300);
setposition(LB+10,INFO+5);
for(cnt = 0;cnt < 3;cnt++)
{
printf(".");
Sleep(300);
}
}
system("cls");
save();
Sleep(200);
login1();
}
else {
printf("注册失败");
Sleep(300);
system("cls");
login1();
}
return;
}
int newok(char * aid,char * apass,char* book1,char* book2,char* book3,int booknum)
{
me *new1 = NULL;
me *now = head;
new1 = (me*)malloc(sizeof(me));
if(new1 == NULL)
{
return 0;//返回0表示失败
}
if(head==NULL)
{
head = new1;
new1->next = NULL;
}
else{
while(now->next!=NULL)
{
now = now->next;
}
now->next = new1;
}
new1->next = NULL;
strcpy(new1->id,aid);
strcpy(new1->pass,apass);
strcpy(new1->book1,book1);
strcpy(new1->book2,book2);
strcpy(new1->book3,book3);
new1->booknum = booknum;
return 1;
}
void showall()
{
system("cls");
showtitle();
admin_BOOK_info();
me *now = head;
if(now == NULL)
{
printf("用户信息丢失!");
}
else{
int k = 0;
while(now!=NULL)
{
setposition(LB,INFO+k);
k++;
char dat1[20],dat2[20],dat3[20];
strcpy(dat1,now->book1);
strcpy(dat2,now->book2);
strcpy(dat3,now->book3);
if(strcmp(dat1 , "o") == 0) {dat1[0] = ' ' ; dat1[1] = 0;}
if(strcmp(dat2 , "o") == 0) {dat2[0] = ' ' ; dat2[1] = 0;}
if(strcmp(dat3 , "o") == 0) {dat3[0] = ' ' ; dat3[1] = 0;}
printf("ID = %s PASSWORD = %s CLASS:%s %s %s",now->id,now->pass,dat1,dat2,dat3);
now = now->next;
}
if(k == 0){
setposition(LB,INFO);
clean();
setposition(LB,INFO);
printf("用户细信息丢失");
}
setposition(LB,INFO+k);
}
system("pause");
admin_BOOK_choice();
}
void ID()
{
system("cls");
showtitle();
admin_BOOK_info();
me *now = head;
char id[20];
setposition(LB,INFO);
printf("输入用户的ID");
fflush(stdin);
scanf("%s",id);
fflush(stdin);
if(now == NULL)
{
printf("用户信息丢失!");
}
else{
int k = 1;
while(now!=NULL)
{
if(strcmp(now->id,id) == 0)
{
change = now;
setposition(LB,INFO+k);
k++;
char dat1[20],dat2[20],dat3[20];
strcpy(dat1,now->book1);
strcpy(dat2,now->book2);
strcpy(dat3,now->book3);
if(strcmp(dat1 , "o") == 0) {dat1[0] = ' ' ; dat1[1] = 0;}
if(strcmp(dat2 , "o") == 0) {dat2[0] = ' ' ; dat2[1] = 0;}
if(strcmp(dat3 , "o") == 0) {dat3[0] = ' ' ; dat3[1] = 0;}
printf("ID = %s PASSWORD = %s CLASS:%s %s %s",now->id,now->pass,dat1,dat2,dat3);
break;
}
now = now->next;
}
if(k == 1){
setposition(LB,INFO+1);
clean();
setposition(LB,INFO+1);
printf("不存在该用户");
Sleep(800);
admin_BOOK_choice();
}
setposition(LB,INFO+k);
}
system("pause");
return;
}
void in()
{
if((fp = fopen("norusers.dat","r"))==NULL)
{
if((fp = fopen("norusers.dat","w"))==NULL)
printf("\nopen error\n");
else {
close();
return;
}
}
head = NULL;
if(fgetc(fp)==EOF) return;
rewind(fp);
while(!feof(fp))
{
char a[20],b[20],book1[20],book2[20],book3[20];
int booknum;
fscanf(fp,"%s%s%s%s%s%d",a,b,book1,book2,book3,&booknum);
newok(a,b,book1,book2,book3,booknum);
}
close();
}
void save()
{
setposition(LB,INFO+3);
me *now = head;
if((fp = fopen("norusers.dat","w"))==NULL)
{
printf("打开文件失败");
exit(0);
}
while(now!=NULL)
{
fprintf(fp," %s %s %s %s %s %d",now->id,now->pass,now->book1,now->book2,now->book3,now->booknum);
now = now->next;
}
close();
return;
}
void close()
{
setposition(LB,INFO+3);
if(fclose(fp))
{
printf("关闭文件失败");
exit(0);
}
}
int space(char *a)
{
int i,sum = 0;
for(i = 0; i <strlen(a);i++)
{
if(a[i] == ' ') sum++;
}
return sum;
}
int AI()
{
int a,b;
srand(time(NULL));
a = rand();
if(a <= 999)
{
a += 1000;
}
setposition(LB,INFO+3);
printf("请输入验证码:%d",a%10000);
setposition(LB+14,INFO+4);
scanf("%d",&b);
fflush(stdin);
if(a%10000 == b) return 0;
else return 1;
}

@ -0,0 +1,34 @@
#ifndef LOGIN_H_INCLUDED
#define LOGIN_H_INCLUDED
#include "BOOKUI.h"
#include "user.h"
#include <time.h>
#include "BOOKS.h"
#include "admin.h"
FILE *fp;
typedef struct memer{
char id[20],pass[20];
char book1[20],book2[20],book3[20];
int booknum;
struct memer *next;
}me;
me*change;
me*user;
void newone();//输入新增用户
int newok(char * aid,char * apass,char* book1,char* book2,char* book3,int booknum);//新增用户写入链表
void showall();//展示
void in();//从文件读取用户数据
void close();//关闭文件
void save();//储存现有数据
int regist();//注册
void info();//提示信息
int space(char*);//空格检测
int AI();//验证码
int loginuser();//普通用户登陆
void logininfo();//登陆提示
void enter();//登陆的实际操作
void ID();//筛选ID
#endif // LOGIN_H_INCLUDED

@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

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