|
|
|
@ -0,0 +1,193 @@
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<string.h>
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
#include<math.h>
|
|
|
|
|
#include<windows.h>
|
|
|
|
|
|
|
|
|
|
FILE *fp;//文件指针
|
|
|
|
|
int i_entry=0;//学生的人数统计
|
|
|
|
|
#define MIN_C 100//每个数据对应字符串类型占据的大小
|
|
|
|
|
#define MAX_G 1000//学生信息量大小
|
|
|
|
|
struct student {
|
|
|
|
|
char stuid[MIN_C];//学生学号
|
|
|
|
|
char name[MIN_C];//学生姓名
|
|
|
|
|
char age[3];//学生年龄
|
|
|
|
|
char gender[MIN_C];//学生性别
|
|
|
|
|
char birth[MIN_C];//学生出生日期
|
|
|
|
|
char add[MIN_C];//学生地址
|
|
|
|
|
char tle[MIN_C];//学生电话
|
|
|
|
|
char email[MIN_C];//学生邮箱
|
|
|
|
|
}DATA[MAX_G];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct student temp[MAX_G];//用于排序的中间变量
|
|
|
|
|
struct student are;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//被调函数
|
|
|
|
|
void init();//文件的初始化读入
|
|
|
|
|
void GREEN();//控制台颜色为绿色
|
|
|
|
|
void RED();//控制台调整前景色为红色
|
|
|
|
|
void LIGHT();//控制台调整前景色为强光
|
|
|
|
|
|
|
|
|
|
void deal();//处理数据
|
|
|
|
|
//dell()函数包含的自定义函数
|
|
|
|
|
void notice();//提示信息
|
|
|
|
|
void case1();//学生综合信息录入
|
|
|
|
|
void entry();
|
|
|
|
|
void file_save();
|
|
|
|
|
|
|
|
|
|
void case2();//学生综合信息浏览
|
|
|
|
|
void i_printf();
|
|
|
|
|
|
|
|
|
|
void case3();//综合信息排序浏览
|
|
|
|
|
void stuid_sort(int I,int L);
|
|
|
|
|
void name_sort(int I,int L);
|
|
|
|
|
|
|
|
|
|
void case4();//学生个人信息查询
|
|
|
|
|
void stuid_find();
|
|
|
|
|
void name_find();
|
|
|
|
|
|
|
|
|
|
void case5();//学生综合信息修改
|
|
|
|
|
void Change(int x);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{ GREEN();
|
|
|
|
|
printf(">********* 亲 ><欢迎使用学生信息管理系统 *********<\n");
|
|
|
|
|
printf(">*********亲 请输入正确的密码,超过三次错误将退出系统哦\n");
|
|
|
|
|
int u=3;
|
|
|
|
|
|
|
|
|
|
char s[15];
|
|
|
|
|
while(u--)
|
|
|
|
|
{if(u==2)
|
|
|
|
|
printf("亲 请输入正确密码 ") ;
|
|
|
|
|
else
|
|
|
|
|
printf("亲,您的密码有误,请重新输入");
|
|
|
|
|
scanf("%s",s);
|
|
|
|
|
if(strcmp("asdfghjkl",s)==0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if(u==0)
|
|
|
|
|
{ GREEN();
|
|
|
|
|
printf(" 》******* 亲您的密码输入有误,sorry\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if((fp=fopen("student_data.txt","r+"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("FILE\n");
|
|
|
|
|
fp=fopen("student_data.txt","w+");
|
|
|
|
|
}
|
|
|
|
|
init();//文件的初始化读入
|
|
|
|
|
LIGHT();
|
|
|
|
|
printf("当前总人数:%d\n",i_entry);
|
|
|
|
|
GREEN();//控制台颜色为绿色
|
|
|
|
|
printf(">********** 欢迎您使用学生信息管理系统(1.1) **********<\n");
|
|
|
|
|
printf(">********** 请输入以下命令行所对应的数字进行操作: **********<\n");
|
|
|
|
|
printf(">**********请确定正确退出程序,否则文件将不能被正常保存。**********<\n");
|
|
|
|
|
deal();//处理数据
|
|
|
|
|
fclose(fp);//文件正常关闭
|
|
|
|
|
return 0;
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
|
|
void init() //文件的初始化读取
|
|
|
|
|
{
|
|
|
|
|
while (!feof(fp))
|
|
|
|
|
{
|
|
|
|
|
fscanf(fp, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", DATA[i_entry].stuid, DATA[i_entry].name, DATA[i_entry].age,
|
|
|
|
|
DATA[i_entry].gender, DATA[i_entry].birth, DATA[i_entry].add, DATA[i_entry].tle, DATA[i_entry].email);
|
|
|
|
|
i_entry++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RED() {//控制台调整前景色为红色
|
|
|
|
|
HANDLE kai_1 = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
|
SetConsoleTextAttribute(kai_1, FOREGROUND_INTENSITY | FOREGROUND_RED); // 为红色
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GREEN() {//控制台调整前景色为绿色
|
|
|
|
|
HANDLE kai_2 = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
|
SetConsoleTextAttribute(kai_2, FOREGROUND_INTENSITY | FOREGROUND_GREEN);// 为绿色
|
|
|
|
|
}
|
|
|
|
|
void LIGHT(){
|
|
|
|
|
HANDLE kai_2 = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
|
SetConsoleTextAttribute(kai_2, FOREGROUND_INTENSITY | FOREGROUND_INTENSITY);// 为强光
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void deal() {//主要处理函数
|
|
|
|
|
int k,flag,p;
|
|
|
|
|
p=1;
|
|
|
|
|
notice();
|
|
|
|
|
flag=1;
|
|
|
|
|
while(flag) {
|
|
|
|
|
if(p>1)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
notice();
|
|
|
|
|
}
|
|
|
|
|
scanf("%d",&k);
|
|
|
|
|
system("cls");
|
|
|
|
|
switch(k) {
|
|
|
|
|
case 0: {
|
|
|
|
|
puts("温馨提醒:");
|
|
|
|
|
puts("\t ^…………^……^^谢谢您的支持,欢迎再次使用!^^……^…………^ ");
|
|
|
|
|
puts("\t*******学生基本信息已保存在当前目录文件 student_data.txt 下********");
|
|
|
|
|
flag=0;
|
|
|
|
|
LIGHT();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 1: {
|
|
|
|
|
case1();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2: {
|
|
|
|
|
case2();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 3: {
|
|
|
|
|
case3();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 4: {
|
|
|
|
|
case4();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 5: {
|
|
|
|
|
case5();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: {
|
|
|
|
|
RED();
|
|
|
|
|
printf("请正确键入命令前数字!\n");
|
|
|
|
|
GREEN();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
p=1103;
|
|
|
|
|
puts("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void notice() {//提示信息
|
|
|
|
|
RED();
|
|
|
|
|
puts("\t\t\t1.学生综合信息录入");
|
|
|
|
|
puts("\t\t\t2.学生综合信息浏览");
|
|
|
|
|
puts("\t\t\t3.综合信息排序浏览");
|
|
|
|
|
puts("\t\t\t4.学生个人信息查询");
|
|
|
|
|
puts("\t\t\t5.学生综合信息修改");
|
|
|
|
|
printf("\t\t\t0. 退 出 系 统\n");
|
|
|
|
|
GREEN();
|
|
|
|
|
printf("请键入:");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|