C语言编写档案管理系统

来源:互联网 发布:cms采集插件 编辑:程序博客网 时间:2024/04/29 01:59

点击这里下载本程序!

界面效果界面效果界面效果界面效果界面效果界面效果

 

#include <stdio.h>#include <stdlib.h>#include<windows.h>#include<ctype.h>#include<conio.h>#include<string.h>#define LEN sizeof(struct Student)/* ClassInfoManage---Author:Ziegler Penn---Language:C---Date:2012.06*//* 班级档案管理系统----作者:彭紫梁----语言:C----日期:2012年6月 */ //-----学生结构体数据原型----- struct Student{char s_Code[10];char s_Name[10];char s_Sex[10];char s_Age[10];char s_Info[50];struct Student * next;};//-----函数声明----- void check_Pass();void cim_load();void cim_exit();void check_input(char * check_Od);void warning (char str[]);void outputInfo(struct Student *head);void add(struct Student * head);void findInfo(); struct Student * del(struct Student *head);void  modify(struct Student *head);void findall(char *chw,struct Student *head,int onum);void helpme (void);//-----登录验证-----void check_Pass() {system("title 登录系统口令验证......");system("mode con:cols=60 lines=10");system("color 1F");char s_Pass[10] = "1234";char login_Pass[20];printf("\n  ┎┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┒\n");    printf("  ┃                班级档案管理系统                  ┃\n");     printf("  ┃┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┚\n");     printf("  ┖输入登录口令:");    Beep(800,800);int i = 0;for(i = 0;i < 20;i++) {login_Pass[i] = getch();Beep(1000,80);if(login_Pass[i] == 8) {if(i == 0) {i-=1;continue;}if(i == 1){system("cls");printf("\n  ┎┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┒\n");    printf("  ┃                班级档案管理系统                  ┃\n");     printf("  ┃┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┚\n");     printf("  ┖输入登录口令:");}int s = 0;for(s = 0;s < i-1;s++) {if(s == 0) {system("cls");printf("\n  ┎┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┒\n");    printf("  ┃                班级档案管理系统                  ┃\n");     printf("  ┃┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┚\n");     printf("  ┖输入登录口令:");}printf("*");}//printf("%d\n",i);//功能调试代码i -= 2;//printf("%d\n",i);//功能调试代码continue;}if(i == 19 && !(login_Pass[i+2] == 8)) {//printf("Join%d\n",i);//功能调试代码i -= 1;continue;}if(login_Pass[i] == 13) {break;}printf("*");}//printf("加结束标记之前的i值:%d  ",i);//功能调试代码 login_Pass[i] = '\0';//printf("PASS:%s",login_Pass);//功能调试代码//Sleep(5000);//功能调试代码if(strcmp(login_Pass,s_Pass) == 0) {system("cls");printf("\n -正在登录Loading............");int tm;for(tm = 0;tm < 100;tm++) {if(tm%20 == 0) {Beep(2000,80);printf("\n");}printf("\r  ...................................................%d%%",tm+1);Sleep(10);}Sleep(200);system("cls");Sleep(200);Sleep(50);}else {system("color 4F");system("cls");warning(" 异常,口令无效,登录失败");Sleep(1000);exit(0);}} //-----系统登录动画函数----- void cim_load() {system("color F1");system("mode con:cols=50 lines=1");system("title 正在载入系统......");int tm;for(tm = 0;tm <25;tm++) {printf("█");Sleep(50);}} //-----系统退出动画函数-----void cim_exit() {system("mode con:cols=50 lines=30");system("cls");printf("\n★正在退出系统!\n\n");printf(" █ ☆█ ◢◤◥◣ ███◣ ███◣ █ ☆█\n");Beep(2000,80);Sleep(150);printf(" █▅▅█ █▄▄█ █ ☆█ █ ☆█ ◥███\n");Beep(2000,80);Sleep(150);printf(" █  █ █  █ ███◤ ███◤    █\n");Beep(2000,80);Sleep(150);printf(" █  █ █ ☆█ █   ☆█   ☆◥██◤\n\n");Beep(2000,80);Sleep(150);printf("         █ ☆真 ◢██◣ █~ ~█* ◢██◣\n");Beep(2000,80);Sleep(150);printf("         █ ≈ █¤ ¤█ █好 爱█≈█▅▅█\n");Beep(2000,80);Sleep(150);printf("         █ * * █的 █ ◥◣◢◤ █☆你▂\n");Beep(2000,80);Sleep(150);printf("         ███◣◥██◤☆ ◥◤ * *◥██◤\n");Beep(2000,80);Sleep(150);printf("\n\n★成功退出系统!\n");Beep(2000,80);Sleep(500);system("color 1F");printf("\n★班级档案管理系统==作者:彭紫梁★\n");printf("\n★HTTP://WWW.VIOLEP.COM★\n");Beep(800,800);Sleep(1000);}//-----判断是否逻辑函数-----int yesOrNo(char *chw) {int onum = 4; while(1) {if(*chw == 'Y' || *chw == 'y') {return 1;break;}else if (*chw == 'N' || *chw == 'n') {return 0;break;}else {printf(" -输入有误,请重新输入!\n -");fflush(stdin);scanf("%c",chw);}}} //-----检测操作安全函数----- void check_input(char * check_Od) {while(1) {if(isdigit(* check_Od)) {break;}else{printf("      ┃━检测到非法输入,重试:");fflush(stdin);int i = 3;for(;i > 0;i-- ){Beep(800,100);}scanf("%c",check_Od);}}}//------警告函数-----void warning (char str[]) {system("color 4F");printf("\n ★★警告★★\n"); int i = 3;for(;i > 0;i-- ) {Beep(800,100);}printf(" -%s",str);Sleep(800);system("color 0E");} //-----创建节点函数-----int n = 0;struct Student * creat(void) {printf("\n ===================★当前操作:录入数据信息★===================\n");struct Student * head;struct Student * p,* q;p = q = (struct Student * )malloc(LEN);printf("\n -依次输入'学号','姓名','性别','年龄','备注',以空格隔开:\n"); head = NULL;int tmp = 0;char chw = 'Y';while(yesOrNo(&chw)) {n = n + 1;tmp = tmp + 1;printf("\n -");scanf("%s %s %s %s %s",p->s_Code,p->s_Name,p->s_Sex,p->s_Age,p->s_Info);if(tmp == 1) {head = p;}else{q->next = p;}q = p;p = (struct Student * )malloc(LEN);system("color 4F");Beep(2000,80);printf(" -录入成功!还要继续吗? 等待输入(Y/N):");fflush(stdin);scanf("%c",&chw);Beep(2000,80);Sleep(300);system("color 0E");}q->next = NULL;printf("\n ==========================★结束操作★==========================\n\n\n");Beep(800,100);Sleep(200);    return (head);  }//-----添加节点函数-----void add(struct Student * head) {printf(" 执行添加函数\n");struct Student *p;p = head;while(p->next != NULL) {p = p->next;}printf(" 找到最后一个节点,学号信息为%s:\n",p->s_Code);p->next = creat();} //-----输出链表-----void outputInfo(struct Student *head) {system("cls");system("color 1F");printf(" ===================★当前操作:显示数据信息★===================\n");if(n == 0) {warning("当前没有录入数据!"); }else {struct Student *p;printf("\n ◆显示当前%d项数据◆\n\n",n);printf("%10s %10s %5s %5s %20s\n","学号","姓名","性别","年龄","备注"); printf(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");p = head;if(head!=NULL) {do{Sleep(200);Beep(2000,80);printf("\n%10s %10s %5s %5s %20s\n",p->s_Code,p->s_Name,p->s_Sex,p->s_Age,p->s_Info);printf(" ________________________________________________________________");p = p->next;} while(p!=NULL);}}printf("\n\n ==================★操作结束,按任意键继续程序★=================\n\n");if(n != 0) {system("pause>nul");}Beep(800,800);printf("\n\n");system("color 0E");}//-----删除数据函数-----struct Student * del(struct Student *head) {struct Student *p,*tmp = NULL;p = head;system("cls");printf(" ===================★当前操作:删除数据信息★===================\n\n");if(n == 0) {warning("当前没有录入数据,无法继续执行操作!");}else {printf(" 输入需要删除项的学号:");char str[10];scanf("%s",str); Beep(2000,80);int onum = 0;for(onum = 0;onum < n;onum++) {if(strcmp(p->s_Code,str) == 0) {if(p->next == NULL) {//判断是否只存在一项数据if(n == 1) {p = NULL;printf(" 删除唯一数据成功!\n");n = n - 1;}break;}else if (!strcmp(p->s_Code,str)) {//判断是否是头部信息p = p->next;n = n - 1;printf(" 删除头部数据成功!\n");head = p; break;}}else {tmp = p;p = p->next;if(onum == (n-1)) {printf(" 没有查找到相应数据!\n"); break; }if(strcmp(p->s_Code,str) == 0) {tmp->next = p->next;printf(" 删除中间(尾部)数据成功!\n");n = n -1;break;}continue;}}} Beep(800,800);printf("\n ==========================★结束操作★==========================\n\n\n");return head;}//-----修改数据函数----- void  modify(struct Student *head) {check_Pass();system("mode con:cols=66 lines=300");system("title 班级档案管理系统");system("color 0E");printf("\n ★口令验证通过★\n\n");printf(" ===================★当前操作:修改数据信息★===================\n");struct Student *p;p = head;if(n == 0) {warning("当前没有录入数据,无法继续执行操作!");}else {printf(" 输入需要修改项的学号:");char str[10];scanf("%s",&str); Beep(2000,80);int onum = 0;int amark = 0;for(onum = 0;onum < n;onum++) {if(strcmp(p->s_Code,str) == 0) {printf(" 查找到你要修改的项:\n"); amark += 1;printf("\n %10s %10s %5s %5s %20s\n","1:学号","2:姓名","3:性别","4:年龄","5:备注"); printf(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");printf("\n %10s %10s %5s %5s %20s\n",p->s_Code,p->s_Name,p->s_Sex,p->s_Age,p->s_Info);printf("\n 输入需要修改的数据项(1~5)操作不可逆:");int tmp;scanf("%d",&tmp); if(tmp == 1||tmp == 2||tmp == 3||tmp == 4||tmp == 5) {switch(tmp) {case 1:printf("\n 你选择了修改学号信息,输入新值:"); Beep(2000,80);scanf("%s",str);strcpy(p->s_Code,str);break;case 2:printf("\n 你选择了修改姓名信息,输入新值:");Beep(2000,80);scanf("%s",str); strcpy(p->s_Name,str);break;case 3:printf("\n 你选择了修改性别信息,输入新值:");Beep(2000,80);scanf("%s",str); strcpy(p->s_Sex,str);break;case 4:printf("\n 你选择了修改年龄信息,输入新值:");Beep(2000,80);scanf("%s",str); strcpy(p->s_Age,str);break;case 5:printf("\n 你选择了修改备注信息,输入新值:");Beep(2000,80);char strInfo[50]; scanf("%s",strInfo);strcpy(p->s_Info,strInfo); break;}printf("\n 操作成功!");}else {Beep(2000,80);printf(" 输入错误,无法继续!\n");}break;}else {p = p->next;}}if(amark == 0) {warning (" 没有查找到数据,无法继续!");}} Beep(800,800);printf("\n ==========================★结束操作★==========================\n\n\n");}//-----查询数据函数-----void findInfo(struct Student *head) {system("cls");printf(" ===================★当前操作:查询数据信息★===================\n\n\n");printf("      ┎┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┒\n");    printf("      ┃                信息查询系统菜单                  ┃\n");     printf("      ┃┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┃\n");     printf("      ┃━ 1.按学号查询    2.按姓名查询    3.按性别查询 ━┃\n");     printf("      ┃━ 4.按年龄查询    0.退 出 查询                 ━┃\n");    printf("      ┖┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┚\n");printf("      ┃━ 请输入操作序号:"); int onum;char str[10];scanf("%d",&onum); if(onum == 1||onum == 2||onum == 3||onum == 4||onum == 5) {switch(onum) {case 1:printf("\n 你选择了按学号查询,输入学号:"); Beep(2000,80);scanf("%s",str);findall(str,head,1);break;case 2:printf("\n 你选择了按姓名查询,输入姓名:");Beep(2000,80);scanf("%s",str); findall(str,head,2);break;case 3:printf("\n 你选择了按性别查询,输入性别:");Beep(2000,80);scanf("%s",str); findall(str,head,3);break;case 4:printf("\n 你选择了按年龄查询,输入年龄:");Beep(2000,80);scanf("%s",str); findall(str,head,4);break;case 0:break;}printf("\n 操作成功!\n");}else {warning(" 输入错误,无法继续!");printf("\n");}Beep(800,800);printf(" ==========================★结束操作★==========================\n\n\n");} //-----查询遍历函数-----void findall(char *chw,struct Student *head,int onum) {int i = 0;int amark = 0;switch(onum) {case 1:for(i = 0;i < n;i++) {if(strcmp(head->s_Code,chw) ==0 ) {amark += 1;printf("\n %10s %10s %5s %5s %20s\n",head->s_Code,head->s_Name,head->s_Sex,head->s_Age,head->s_Info);}head = head->next;} if(amark == 0) {warning ("查询完毕,没有查找到内容!");}break;case 2:for(i = 0;i < n;i++) {if(strcmp(head->s_Name,chw) ==0 ) {amark += 1;printf("\n %10s %10s %5s %5s %20s\n",head->s_Code,head->s_Name,head->s_Sex,head->s_Age,head->s_Info);}head = head->next;} if(amark == 0) {warning ("查询完毕,没有查找到内容!");}break;case 3:for(i = 0;i < n;i++) {if(strcmp(head->s_Sex,chw) ==0 ) {amark += 1;printf("\n %10s %10s %5s %5s %20s\n",head->s_Code,head->s_Name,head->s_Sex,head->s_Age,head->s_Info);}head = head->next;} if(amark == 0) {warning ("查询完毕,没有查找到内容!");}break;case 4:for(i = 0;i < n;i++) {if(strcmp(head->s_Age,chw) ==0 ) {amark += 1;printf("\n %10s %10s %5s %5s %20s\n",head->s_Code,head->s_Name,head->s_Sex,head->s_Age,head->s_Info);}head = head->next;} if(amark == 0) {warning ("查询完毕,没有查找到内容!");}break;}}  //-----保存文件-----int savedoc = 0;void  saveData(struct Student *head) {printf(" =====================★当前操作:保存文件★=====================\n");warning ("正准备保存文件....");if(n == 0) {warning(" 当前没有创建数据,无法操作用户请求!");}else {struct Student *p;p = head;FILE *fp = fopen("Info.data","w");int tm;if(fp != NULL) {for(tm = 0; tm < n; tm++) {fprintf(fp,"%10s %10s %10s %10s %20s \n",p->s_Code,p->s_Name,p->s_Sex,p->s_Age,p->s_Info);p = p->next;}fclose(fp);}savedoc += 1;Sleep(500);printf(" ★文件保存成功!★\n");}Beep(800,800);printf("\n ===================★结束操作:查询数据信息★===================\n\n\n");}//-----帮助函数-----void helpme (void) {system("cls");system("color 1F");printf(" =====================★当前操作:帮助信息★=====================\n\n");Beep(2000,80);Sleep(150);printf(" =        班级档案管理系统,可实现基本的数据增删改查操作,主要使 =\n");Beep(2000,80);Sleep(150);printf(" = 用动态链表和结构体相关知识作为核心原理实现,可将数据保存成文 =\n");Beep(2000,80);Sleep(150);printf(" = 本文件,便于使用,本系统由彭紫梁(ZIEGLER PENN)制作。         =\n");Beep(2000,80);Sleep(150);printf(" = ____________________________________________________________ =\n");Beep(2000,80);Sleep(150);printf(" =                                        HTTP://WWW.VIOLEP.COM =\n");Beep(2000,80);Sleep(150);printf(" =  ★□■□■□■□■□■□■□■ □■□■□■□■□■□■□★ =\n");Beep(2000,80);Sleep(150);printf(" =  ☆∴.﹡﹒*﹒。.☆....﹒。.∴*'.﹒..∴☆..﹒. ﹒..∴☆ =\n");Beep(2000,80);Sleep(150);printf(" =  ┌═╮◆╭═┐╭═┐╭═┐╭═┐╭═┐╭═┐ ╭═┐◆╭═┐ =\n");Beep(2000,80);Sleep(150);printf(" =  ║┌╯◆║杀║║人║║从║║不║║用║║刀║ ║!!!║◆╰┐║=\n");Beep(2000,80);Sleep(150);printf(" =  ╰╯↘◆└═╯└═╯└═╯└═╯└═╯└═╯ └═╯◆↙╰╯ =\n");Beep(2000,80);Sleep(150);printf(" =  ☆∴.﹡﹒*﹒。.☆...﹒。.∴.*'.﹒..∴☆..﹒. ﹒..∴☆ =\n");Beep(2000,80);Sleep(150);printf(" =  ★□■□■□■□■□■□■□■ □■□■□■□■□■□■□★ =\n\n");Beep(2000,80);Sleep(150);printf(" = ============================================================ =\n");Beep(2000,80);Sleep(150);printf(" = =                            工具箱                          =\n");Beep(2000,80);Sleep(150);printf(" = ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ =\n");printf(" = =      1:计算器      2:记事本     3:命令提示符(当前)      =\n");printf(" = ============================================================ =\n");Beep(2000,80);Sleep(150);printf("┃━ 请输入操作序号(按0退出):");char menu;fflush(stdin);scanf("%c",&menu);int i = 1; switch(menu) {case '1':system("calc");break;case '2':system("notepad");break;case '3':system("cmd");case '0':break;default:printf(" 错误的操作选择!\n");} printf("\n ==================★操作结束,按任意键继续程序★=================\n");system("pause>nul");Beep(800,800);system("color 0E");}  int main(int argc, char *argv[]) {cim_load();check_Pass();system("mode con:cols=66 lines=300");system("title 班级档案管理系统");system("color 0E");printf("\n ★登录成功★\n\n");Beep(1000,600);char menu;while(1) {printf("      ┎┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┒\n");        printf("      ┃                     系统菜单                     ┃\n");         printf("      ┃┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┃\n");         printf("      ┃━  1.信息录入 2.信息修改 3.信息删除 4.信息查询 ━┃\n");         printf("      ┃━  5.保存文件 6.信息显示 7.帮助信息 0.退出系统 ━┃\n");    printf("      ┠┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┨\n");    printf("      ┃━                班级档案管理系统 作者:彭紫梁 ━┃\n");        printf("      ┖┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┚\n");printf("      ┃━ 请输入操作序号:"); fflush(stdin);scanf("%c",&menu);check_input(&menu);struct Student * head;switch(menu) {case '0':if(savedoc == 0) {warning("文件尚未保存,确认退出吗?(Y/N)");char tmp[5];fflush(stdin);scanf("%s",&tmp);if(!yesOrNo(tmp)) {break;} }Beep(800,100);cim_exit();exit(0);case '1':system("cls"); Beep(800,100);if(n != 0) {add(head);}else {head = creat();}Sleep(200);break;case '2':Beep(800,100);modify(head);break;case '3':Beep(800,100);head = del(head);break;case '4':Beep(800,100);findInfo(head);break;case '5':Beep(800,100);saveData(head);break;case '6':Beep(800,100);outputInfo(head);break;case '7':Beep(800,100);helpme ();break;default:warning("无此操作序号,重试!");system("cls");}}}


 


 

原创粉丝点击