银行管理系统(c链表实现)
只是想存个代码源的卑微女大学生
另一个逆波兰式的回答
下附源代码
/********************************头文件调用*********************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <time.h>
#include <windows.h>/***************************银行客户信息结构体管理员***********************************/
struct Client; //银行客户信息结构体声明
typedef struct Client Client, *Ptrone; //结构体指针定义
typedef Ptrone List; //链表头指针定义
typedef Ptrone Position; //链表结点指针定义/********************************存取款记录结构体**************************************/
struct Records; //职称结构体声明
typedef struct Records Records, *PtrRe; //结构体指针定义
typedef PtrRe List1; //链表头指针定义
typedef PtrRe Position1; //链表结点指针定义/********************************链表函数声明******************************************/
void DeleteList(List L); //链表删除函数(客户信息
List MakeEmpty(List L); //空链表创建函数(客户信息
void BianliList(List L); //遍历客户信息链表函数
List SortMoney(List L); //链表冒泡排序函数(余额
List SortNum(List L); //链表冒泡排序函数(账号
void DeleteList1(List1 L); //链表删除函数(收支记录
List1 MakeEmpty1(List1 L); //空链表创建函数(收支记录
void BianliList1(List1 L); //遍历收支记录链表函数
List1 SortNum1(List1 L); //操作记录(账号
List1 SortTime1(List1 L); //操作记录(时间/********************************文件函数声明******************************************/
List Load(List L); //将客户信息加载到内存函数
void Save(List L); //将客户信息保存到磁盘函数
void MakeFileEmpty(); //清空文件函数
List1 Load1(List1 L); //将收支记录信息加载到内存函数
void Save1(List1 L); //将收支记录信息保存到磁盘函数
void MakeFileEmpty1(); //清空文件函数/********************************菜单函数声明******************************************/
void Choose(); //访客选择身份
void MainMeun1(List L, List1 L1); //管理员主菜单
void MainMeun2(char[], List L, List1 L1); //客户主菜单
void ViewMeun(List L, List1 L1); //查询客户信息菜单
void RecordMeun(List1 L); //查询客户存取款记录菜单
void OrderMeun(List L, List1 L1); //客户信息排序菜单
void ModMeun(List L, List1 L1); //修改菜单
void ModMeun1(Position p, List L, List1 L1); //修改的部分菜单/********************************客户信息管理函数声明**********************************/void Add(List L); //信息录入函数
void ViewNum(char num[], List L); //账号显示函数
void ViewName(char name[], List L); //姓名信息显示函数
void ViewTel(char tel[], List L); //电话信息显示函数
void ViewID(char ID[], List L); //身份证显示函数
void ViewCom(List L); //综合查询
void CircleTel(char tel[], Position p, List L, List1 L1); //电话
void CircleName(char name[], Position p, List L, List1 L1); //姓名
void CircleID(char ID[], Position p, List L, List1 L1); //身份证查询
void ModName(Position p, List L, List1 L1); //客户姓名修改函数
void ModTel(Position p, List L); //客户电话修改函数
void ModPassword(Position p, List L); //客户密码修改函数
void ModMoney(Position p, List L, double n); //客户余额修改函数
void Delete(List L, List1 L1); //删除函数,客户信息/********************************收支记录管理函数声明**********************************/
void Add1(char sj[], Position p, List L, List1 L1); //收支记录录入函数
void ViewNum1(char num[], List1 L); //收支记录查询函数(按账号
void ViewName1(char name[], List1 L); //收支记录查询函数(按姓名
void ViewCom1(List1 L); //综合查询/********************************功能函数声明******************************************/
Position Logon(List L);
int Mimayincan(char a[]); //密码隐藏函数
void PrintRecords(Position1 p); //收支记录打印函数
void PrintClient(Position P); //客户信息打印函数
int Testl(int a, int b, int c); //菜单输入检测函数
void jieshuo(List L, List1 L1);/*********************************结构体定义*******************************************/
struct Client//客户信息结构体客户
{char num[30]; //账号char ID[19]; //身份证号char name[10]; //姓名char tel[12]; //电话char password[20]; //密码char loc[10]; //办卡地址double money; //余额char sd[5]; //锁定char time[20]; //还款日期int type; //卡类型1.储蓄卡,2.信用卡int point; //信用积分Position next; //next指针 (指向下一结构体)
};
struct Records//操作记录结构体
{char num[30]; //账号char name[20]; //姓名char ID[20];char time[20]; //操作时间 年/月/日,时:分 2019/2/6-17.40double rmb; //存取款char sd[5]; //锁定struct Records *next; //next指针
};
/********************************函数定义**********************************************/
int main()//主函数
{system("color B0");List L = NULL;List1 L1 = NULL;int x;system("cls");printf("\n\n\n\n\t\t\t欢迎进入小仙雕银行~~~~~\n\n");L = Load(L);L1 = Load1(L1);printf("\n\t\t输入回车键继续");getchar();system("cls"); //实现清屏Choose(); //调用访客选择身份函数scanf("%d", &x);x = Testl(x, 0, 2);while (1){fflush(stdin); //清除键盘缓冲区switch (x){case 1: system("cls"); char a[] = "123123";if (Mimayincan(a) == 1)MainMeun1(L, L1);exit(0); //调用管理员主菜单函数case 2: system("cls"); Position p = Logon(L);if (p)MainMeun2(p->num, L, L1); //调用客户主菜单函数elsemain();case 0: exit(0); //退出系统}}return 0;
}/********************************链表函数定义******************************************/
void DeleteList(List L)//链表删除函数
{Position P;P = L->next; //取链表头后的所有结点L->next = NULL; //链表头指向空结点while (P != NULL); //依次释放链表头后所有结点的空间{free(P);P = P->next;}
}
void DeleteList1(List1 L)
{Position1 p;p = L->next; //取链表头后的所有结点L->next = NULL; //链表头指向空结点while (p != NULL); //依次释放链表头后所有结点的空间{free(p);p = p->next;}
}
List MakeEmpty(List L)//空链表创建函数
{if (L) //相当于 if(L!=NULL) ,即指针L指向的空间不为空DeleteList(L); //删除原先链表L = (List)malloc(sizeof(struct Client)); //创建新的空链表if (!L) //相当于 if(L==NULL) ,即指针L指向的空间为空{printf("创建失败,内存不足!!!"); //创建失败,提示内存不足system("pause"); //暂停屏幕显示return NULL; //返回上一级菜单}L->next = NULL; //Next指针指向空return L; //返回链表头
}
List1 MakeEmpty1(List1 L)
{if (L) //相当于 if(L!=NULL) ,即指针L指向的空间不为空DeleteList1(L); //删除原先链表L = (List1)malloc(sizeof(struct Records)); //创建新的空链表if (!L) //相当于 if(L==NULL) ,即指针L指向的空间为空{printf("创建失败,内存不足!!!"); //创建失败,提示内存不足system("pause"); //暂停屏幕显示return NULL; //返回上一级菜单}L->next = NULL; //Next指针指向空return L; //返回链表头
}
void BianliList(List L)//遍历链表函数
{Position p = L->next;printf("\n客户信息如下:\n");printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");printf("账号\t\t\t姓名\t\t电话\t\t办卡地址\t余额\t\t状态 \n");while (p){printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");printf("%-20s\t%-10s\t%-11s\t%-10s\t%-.2lf\t\t%-5s\n", p->num, p->name, p->tel, p->loc, p->money, p->sd);p = p->next;}printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - -\n");system("pause");
}
void BianliList1(List1 L)
{printf("\n\t\t\t\t收支记录如下:\n");printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");printf("账号\t\t\t姓名\t\t操作日期\t\t存取款 \n");Position1 p = L->next;while (p){printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");printf("%-20s\t%-10s\t%-18s\t%-.2lf \n", p->num, p->name, p->time, p->rmb);p = p->next;}printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");system("pause");
}/********************************文件函数定义******************************************/
List Load(List L)//初始化函数
{FILE *fp;Position a;int num = 0;fp = fopen("客户信息.txt", "r+");if (fp == NULL){printf("\n\t\t无法打开文件或文件不存在\n"); //提示错误printf("\n\t\t正在尝试创建新文件....\n");fp = fopen("客户信息.txt", "w"); //创建客户信息文件if ((fp = fopen("客户信息.txt", "r+")) == NULL){printf("\t\t文件创建失败!!!\n");system("pause"); //暂停屏幕显示return NULL;}}fp = fopen("客户信息.txt", "r+"); //以只读的方式打开"客户信息.txt"文本文件L = MakeEmpty(L); //创建链表,以便存储文本文件中的信息while (1){a = (List)malloc(sizeof(struct Client)); //创建新结点if (a == NULL){printf("\n\t\t文件信息读取失败,系统内存不足!");system("pause"); //暂停屏幕显示return NULL;}if (fscanf(fp, "%s %s %s %s %s %s %lf %s %d %d %s", a->num, a->ID, a->name, a->tel, a->password, a->loc, &a->money, a->time, &a->type, &a->point, a->sd)<0)break; //将客户信息录入文件a->next = L->next; //头插法L->next = a;num++;}printf("\n\t\t客户信息读取完成,目前共有%d名客户\n", num);fclose(fp);return L;
}
List1 Load1(List1 L)
{FILE *fp;Position1 a;int num = 0;fp = fopen("收支记录.txt", "r+");if (fp == NULL){printf("\n\t\t无法打开文件或文件不存在\n"); //提示错误printf("\n\t\t正在尝试创建新文件....\n");fp = fopen("收支记录.txt", "w"); //创建客户信息文件if ((fp = fopen("收支记录.txt", "r+")) == NULL){printf("\t\t文件创建失败!!!\n");system("pause");return NULL; //暂停屏幕显示}}fp = fopen("收支记录.txt", "r+"); //以只读的方式打开"收支记录.txt"文本文件L = MakeEmpty1(L); //创建链表,以便存储文本文件中的信息while (1){a = (List1)malloc(sizeof(struct Records)); //创建新结点if (a == NULL){printf("\n\t\t文件信息读取失败,系统内存不足!");system("pause"); //暂停屏幕显示return NULL;}if (fscanf(fp, "%s %s %s %s %lf %s\n", a->num, a->name, a->time, a->ID, &a->rmb, a->sd)<0)break; //将客户收支记录录入文件a->next = L->next; //头插法L->next = a;num++;}fclose(fp);printf("\n\t\t操作记录信息读取完成,目前共有%d条操作记录\n", num);return L;
}
void Save(List L)//信息保存函数
{FILE *fp;Position p = L;if ((fp = fopen("D:\\客户信息.txt", "w+")) == NULL){printf("打开文件失败\n");system("pause");return;}fp = fopen("客户信息.txt", "w+");while (p->next != NULL){p = p->next;if (fprintf(fp, "%s\t %s\t %s\t %s\t %s\t %s\t %.2lf\t %s\t %d\t %d\t %s\n", p->num, p->ID, p->name, p->tel, p->password, p->loc, p->money, p->time, p->type, p->point, p->sd)<0)break; //将信息写入磁盘}printf("信息录入成功!\n");fclose(fp);return;
}
void Save1(List1 L)
{FILE *fp;Position1 p = L;if ((fp = fopen("D:\\收支记录.txt", "w+")) == NULL){printf("打开文件失败\n");exit(0);}fp = fopen("收支记录.txt", "w+");for (; p->next != NULL;){p = p->next;if (fprintf(fp, "%s\t %s\t %s\t %s\t %.2lf\t %s\n", p->num, p->name, p->time, p->ID, p->rmb, p->sd)<0)break; //将信息写入磁盘}printf("信息录入成功!\n");fclose(fp);
}
void MakeFileEmpty()//清空文件函数
{FILE *fp;fp = fopen("客户信息.txt", "w"); //新建一个文件,并将之前的文件删除if (fp == NULL){printf("文件打开失败\n");exit(0);}printf("信息清空成功!\n");fclose(fp);
}
void MakeFileEmpty1()
{FILE *fp;fp = fopen("收支记录.txt", "w"); //新建一个文件,并将之前的文件删除if (fp == NULL){printf("文件打开失败\n");exit(0);}printf("信息清空成功!\n");fclose(fp);
}/********************************菜单函数定义******************************************/
void Choose()//访客选择身份 @
{printf("\n\t\t** 选择您的身份 **");printf("\n\t\t** **");printf("\n\t\t** 1.管理员 **");printf("\n\t\t** 2.客户 **");printf("\n\t\t** 0.退出系统 **");printf("\n\t\t** **");printf("\n\n\t\t\t请输入您的选择:");
}
void MainMeun1(List L, List1 L1)//管理员主菜单
{system("cls");printf("\n\t\t** 主菜单 **");//printf("\n\t\t** **");//printf("\n\t\t** 1.注册账户 **");//printf("\n\t\t** 2.注销账户 **");//printf("\n\t\t** 3.查询客户信息 **");//printf("\n\t\t** 4.查询客户操作记录 **");//printf("\n\t\t** 5.修改客户信息 **");//printf("\n\t\t** 6.信息查看 **");//printf("\n\t\t** 7.客户后台操作 **");//printf("\n\t\t** 8.重置系统 **");//printf("\n\t\t** 9.账户解锁,挂失,取消挂失 **");//printf("\n\t\t** 0.返回上一层 **");//printf("\n\t\t** **");printf("\n\n\t\t\t请输入您的选择:");int x;scanf("%d", &x);while (1){system("cls"); //实现清屏x = Testl(x, 0, 9);fflush(stdin); //清除键盘缓冲区switch (x){case 1: system("cls"); Add(L); system("cls"); MainMeun1(L, L1); //注册账户case 2: system("cls"); Delete(L, L1); system("cls"); MainMeun1(L, L1); //注销账户case 3: system("cls"); ViewMeun(L, L1); system("cls"); MainMeun1(L, L1); //查询客户信息case 4: system("cls"); RecordMeun(L1); return; //查询客户存取款信息case 5: system("cls"); ModMeun(L, L1); return; //修改客户信息case 6: system("cls"); OrderMeun(L, L1); return; //信息查看case 7: system("cls"); Position p = Logon(L); MainMeun2(p->num, L, L1); MainMeun1(L, L1); break; //客户存取款,修改密码等操作case 8: system("cls"); printf("是否需要重置系统,回复'Y'/'N'\n");if (getchar() == 'Y'){MakeFileEmpty(), MakeFileEmpty1(); system("cls"); return;}//重置系统MainMeun1(L, L1);case 9: system("cls"); jieshuo(L, L1); MainMeun1(L, L1); break; //返回上一层case 0: system("cls"); main(); break; //返回上一层}return;}
}
void MainMeun2(char num[], List L, List1 L1)//客户主菜单
{Position p = L->next;Position1 p1 = L1->next;char sj[20], b[20] = "00";while (p1 != NULL && strcmp(num, p1->num) != 0)p1 = p1->next;while (p != NULL && strcmp(num, p->num) != 0)p = p->next;printf("\n\t\t** 主菜单 **");printf("\n\t\t** **");if (p->type == 1)printf("\n\t\t** 1.存取款 **");//elseprintf("\n\t\t** 1.消费与还款 **");//printf("\n\t\t** 2.操作记录查询 **");//printf("\n\t\t** 3.个人信息查询 **");//printf("\n\t\t** 4.修改密码 **");//printf("\n\t\t** 5.退出客户系统 **");//printf("\n\t\t** **");time_t rawtime;struct tm * timeinfo;time(&rawtime);timeinfo = localtime(&rawtime);//获取系统时间printf("\n\t\t%4d/%02d/%02d-%02d.%02d.%02d\n", 1900 + timeinfo->tm_year, 1 + timeinfo->tm_mon,timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);printf("\n\t\t请输入以上时间(年/月/日-时.分.秒): ");scanf("%s", sj);if (p->money<0 && strcmp(p->time, sj) <= 0)//超时未还款信用分未负,还款金额翻倍{p->point = -1;p->money = 1.1*p->money;printf("\n\t\t%4d/%02d/%02d-%02d.%02d.%02d\n", 1900 + timeinfo->tm_year, 1 + timeinfo->tm_mon + 1,timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);printf("\n\t\t请输入以上时间(年/月/日-时.分.秒): "); //保存操作日期scanf("%s", p->time);Save(L);printf("\n\t\t您的信用分不够啦。希望您可以先还款哦!您需要还款%.2lf元。", -p->money);}if (p->money>0){strcpy(p->time, b);Save(L);}printf("\n\n\t\t\t请输入您的选择:");int x;scanf("%d", &x);while (1){system("cls"); //实现清屏x = Testl(x, 1, 5);fflush(stdin);//清除键盘缓冲区switch (x){case 1: system("cls"); Add1(sj, p, L, L1); system("cls"); MainMeun2(p->num, L, L1); //存款case 2: system("cls"); if (p1->next == NULL){printf("\n无操作记录: ");system("pause");return;}ViewNum1(num, L1); system("cls"); MainMeun2(p->num, L, L1); //操作记录查询case 3: system("cls"); ViewNum(num, L); system("cls"); MainMeun2(p->num, L, L1); //个人信息查询case 4: system("cls"); ModPassword(p, L); system("cls"); MainMeun2(p->num, L, L1); //修改密码case 5: system("cls"); return; //返回上一层}}
}
void OrderMeun(List L, List1 L1)//信息查看菜单
{printf("\n\t\t** 信息查看 **");printf("\n\t\t** **");printf("\n\t\t** 1.按账号排序(客户信息) **");//@printf("\n\t\t** 2.按余额排序(客户信息) **");//@printf("\n\t\t** 3.按账号排序(操作记录) **");//@printf("\n\t\t** 4.按时间排序(操作记录) **");//@printf("\n\t\t** 5.返回上一级菜单 **");//printf("\n\t\t** **");printf("\n\n\t\t\t请输入您的选择:");int x;scanf("%d", &x);while (1){system("cls"); //实现清屏x = Testl(x, 1, 5);fflush(stdin); //清除键盘缓冲区switch (x){case 1: system("cls"); L = SortNum(L); system("cls"); OrderMeun(L, L1); //按账号排序case 2: system("cls"); L = SortMoney(L); system("cls"); OrderMeun(L, L1); //按余额排序case 3: system("cls"); L1 = SortNum1(L1); system("cls"); OrderMeun(L, L1); //按账号排序case 4: system("cls"); L1 = SortTime1(L1); system("cls"); OrderMeun(L, L1); //按时间排序case 5: system("cls"); MainMeun1(L, L1); //返回上一层}}
}
void ViewMeun(List L, List1 L1)//查询客户信息菜单
{printf("\n\t\t** 查询客户信息 **");printf("\n\t\t** **");printf("\n\t\t** 1.按账号查询 **");//@printf("\n\t\t** 2.按身份证查询 **");//@printf("\n\t\t** 3.按姓名查询 **");//@printf("\n\t\t** 4.按电话查询 **");//@printf("\n\t\t** 5.按电话和姓名查询 **");//@printf("\n\t\t** 6.返回上一层 **");//@printf("\n\t\t** **");printf("\n\n\t\t\t请输入您的选择:");int x;scanf("%d", &x);while (1){system("cls"); //实现清屏x = Testl(x, 1, 6);fflush(stdin); //清除键盘缓冲区switch (x){case 1: system("cls"); char num[30]; printf("\n请输入所要查询的账号: ");gets(num); ViewNum(num, L); system("cls"); ViewMeun(L, L1); break; //按账号查询case 2: system("cls"); char ID[20]; printf("\n请输入需要查询的身份证: ");gets(ID); ViewID(ID, L); system("cls"); ViewMeun(L, L1); break; //按身份证号查询case 3: system("cls"); char name[10]; printf("\n请输入需要查询的姓名: ");gets(name); ViewName(name, L); system("cls"); ViewMeun(L, L1); break; //按姓名查询case 4: system("cls"); char tel[20]; printf("\n请输入需要查询的电话: ");gets(tel); ViewTel(tel, L); system("cls"); ViewMeun(L, L1); break; //按电话查询case 5: system("cls"); ViewCom(L); MainMeun1(L, L1); break; //按电话和姓名查询case 6: system("cls"); MainMeun1(L, L1); break; //返回上一层}}
}
void RecordMeun(List1 L1)//查询客户存取款记录菜单
{printf("\n\t\t** 查询客户操作记录 **");printf("\n\t\t** **");printf("\n\t\t** 1.按账号查询 **");//@printf("\n\t\t** 2.按姓名查询 **");//@printf("\n\t\t** 3.按账号和操作时间查询 **");//@printf("\n\t\t** 4.返回上一层 **");//@printf("\n\t\t** **");printf("\n\n\t\t\t请输入您的选择:");int x;List L = NULL;L = Load(L);char num[30], name[10];scanf("%d", &x);while (1){system("cls"); //实现清屏x = Testl(x, 1, 4);fflush(stdin); //清除键盘缓冲区switch (x){case 1: system("cls"); printf("\n请输入所要查询的账号: "); gets(num); ViewNum1(num, L1);system("cls"); RecordMeun(L1);case 2: system("cls"); printf("\n请输入所要查询的姓名: "); gets(name); ViewName1(name, L1);system("cls"); RecordMeun(L1);case 3: system("cls"); ViewCom1(L1); MainMeun1(L, L1); break; //按账号和操作时间查询case 4: system("cls"); MainMeun1(L, L1); //返回上一层}}
}
void ModMeun(List L, List1 L1)//修改菜单
{printf("\n\t\t** 修改客户信息 **");printf("\n\t\t** **");printf("\n\t\t** 1.按账号查询修改 **");//printf("\n\t\t** 2.按姓名查询修改 **");//printf("\n\t\t** 3.按电话查询修改 **");//printf("\n\t\t** 4.按身份证号查询修改 **");//printf("\n\t\t** 5.返回上一层 **");//printf("\n\t\t** **");printf("\n\n\t\t\t请输入您的选择:");int x;char name[10], tel[20], ID[20], num[30], a[20];Position p = L->next;scanf("%d", &x);while (1){system("cls"); //实现清屏x = Testl(x, 1, 5);fflush(stdin); //清除键盘缓冲区switch (x){case 1: system("cls"); printf("\n请输入查询修改的账号: "); gets(num); //按账号查询while (p) //判断P的Next指针是否为空,且P的下一个结点的客户电话是否为查找账号{if (strcmp(num, p->num) == 0){PrintClient(p);printf("\n是否是您想修改的账户:回复'Y'/'N'\n");if (getchar() == 'Y'){strcpy(a, p->password);Mimayincan(a);ModMeun1(p, L, L1);}else{printf("未找到您想要修改的账号~\n");system("pause"); system("cls"); ModMeun(L, L1);}}p = p->next;if (!p){printf("\n该账号不存在: ");system("pause"); system("cls"); ModMeun(L, L1);}}system("cls"); ModMeun(L, L1);case 2: system("cls"); printf("\n请输入查询修改的姓名: "); gets(name); //按姓名查询CircleName(name, p, L, L1); system("cls"); ModMeun(L, L1);case 3: system("cls"); printf("\n请输入查询修改的电话: "); gets(tel); //按电话查询CircleTel(tel, p, L, L1); system("cls"); ModMeun(L, L1);case 4: system("cls"); printf("\n请输入查询修改的身份证号: "); gets(ID); //按身份证查询CircleID(ID, p, L, L1); system("cls"); ModMeun(L, L1);case 5: system("cls"); MainMeun1(L, L1); //返回上一层}}
}
void ModMeun1(Position p, List L, List1 L1)//修改客户信息菜单
{printf("\n\t\t** 修改客户信息 **");printf("\n\t\t** **");printf("\n\t\t** 1.修改姓名 **");//printf("\n\t\t** 2.修改密码 **");//printf("\n\t\t** 3.修改电话 **");//printf("\n\t\t** 4.返回上一层 **");//printf("\n\t\t** **");printf("\n\n\t\t\t请输入您的选择:");int x;scanf("%d", &x);while (1){system("cls"); //实现清屏x = Testl(x, 1, 4);fflush(stdin); //清除键盘缓冲区switch (x){case 1: system("cls"); ModName(p, L, L1); system("cls"); ModMeun1(p, L, L1); //修改姓名case 2: system("cls"); ModPassword(p, L); system("cls"); ModMeun1(p, L, L1); //修改密码case 3: system("cls"); ModTel(p, L); system("cls"); ModMeun1(p, L, L1); //修改电话case 4: system("cls"); ModMeun(L, L1); //返回上一层}}
}/********************************客户管理函数声明********************************************/
//信息录入函数与删除
void Add(List L)//客户信息
{Position p = L->next;char num[20], a[5] = "正常", b[20] = "00";int t;printf("\n请输入所要创建的账号: "); //提示输入账号gets(num);while (p != NULL && strcmp(num, p->num) == 0)p = p->next;if (!p){printf("\n该账号已存在 ");system("pause");return;}p = (Position)malloc(sizeof(struct Client)); //创建新结点if (p == NULL){printf("\n添加失败,内存不足!!!\n\n"); //添加失败,提示内存不足system("pause"); //暂停屏幕显示return; //返回上一级菜单}strcpy(p->num, num); //保存账号printf("\n请输入您需要办理的卡类型(1.储蓄卡2.信用卡): ");scanf("%d", &t);t = Testl(t, 1, 2);p->type = t;printf("\n请输入客户身份证号: "); //保存身份证号scanf("%s", p->ID);printf("\n请输入客户电话: "); //保存电话scanf("%s", p->tel);printf("\n请输入客户的姓名: "); //保存姓名scanf("%s", p->name);printf("\n请输入客户密码: "); //保存密码scanf("%s", p->password);printf("\n请输入客户办卡地址: "); //保存办卡地址scanf("%s", p->loc);p->money = 0.00; //余额p->point = 0; //信用积分strcpy(p->time, b); //还款日期strcpy(p->sd, a); //状态p->next = L->next; //将结点p插入到链表中L->next = p;Save(L); //调用 信息保存函数system("pause");return;
}
void Add1(char sj[], Position p, List L, List1 L1)//收支记录
{char a[5] = "正常", b[20] = "00";Position1 p1;p1 = (Position1)malloc(sizeof(struct Records)); //创建新结点if (p == NULL){printf("\n添加失败,内存不足!!!\n\n"); //添加失败,提示内存不足system("pause"); //暂停屏幕显示}strcpy(p1->num, p->num);strcpy(p1->name, p->name);strcpy(p1->ID, p->ID);strcpy(p1->time, sj);if (p->type == 1)//储蓄卡{printf("\n请输入存取款金额(带符号): "); //保存存取款scanf("%lf", &p1->rmb);if (p->money + p1->rmb < 0){printf("\n余额不足!");system("pause"); return;}p->money = p->money + p1->rmb;}else if (p->type == 2)//信用卡{printf("\n请输入消费或还款金额(带符号): ");scanf("%lf", &p1->rmb);if (p1->rmb<0)//消费金额超过透支额度{if (p->money + p1->rmb < -500 && p->point == 0)//透支额度不够时{printf("\n透支额度不够,您还可以消费%.2lf元", 500 + p->money);system("pause"); return;}else if (p->point<0){printf("\n您的信用分不够,请先还款哦!您需要还款%.2lf元。", p->money);system("pause"); return;}p->money = p->money + p1->rmb;if (p->money<0 && p->point == 0){time_t rawtime;struct tm * timeinfo;time(&rawtime);timeinfo = localtime(&rawtime);//获取系统时间printf("%4d/%02d/%02d-%02d.%02d.%02d\n", 1900 + timeinfo->tm_year, 1 + timeinfo->tm_mon + 1,timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);//还款日期,加一个月printf("\n请输入以上时间(年/月/日-时.分.秒): "); //保存操作日期scanf("%s", p->time);printf("\n请在%s之前还款", p->time);//提醒还款}}if (p1->rmb + p->money >= 0)//违约后还款信用分恢复{p->point = 0;strcpy(p->time, b);}}p1->next = L1->next; //将结点p插入到链表中L1->next = p1;strcpy(p1->sd, a);Save1(L1); //调用 信息保存函数Save(L);system("pause");return;
}
void Delete(List L, List1 L1)//客户信息
{Position p = L->next, a;Position1 p1 = L1->next, b;char num[10];printf("\n请输入想注销的账号: ");gets(num); //按账号删除while (p != NULL&&strcmp(p->num, num) != 0)p = p->next;if (!p){printf("\n不存在该账户哦~\n");system("pause"); return;}PrintClient(p); //调用职工信息打印函数fflush(stdin); //清除键盘缓冲区if (p->money > 0){printf("\n请先取出账户余额!");system("pause");return;}printf("\n是否确认要删除?回复'Y'/'N'\n");if (getchar() == 'Y'){Mimayincan(p->password);a = p->next;p->next = a->next;free(a);while (p1 != NULL) //判断P的Next指针是否为空,且P的下一个结点的客户姓名是否为查找账号if (strcmp(num, p1->num) == 0){b = p1->next;p1->next = b->next;free(b);}printf("\n删除成功!!!\n\n");Save(L); //调用信息保存函数Save1(L1);}
}
//查询函数
void ViewNum(char num[], List L)//账号
{Position p = L->next;int f = 0;while (p){if (strstr(p->num, num)){PrintClient(p);f = 1;}p = p->next;}if (f == 0) //判断是否存在该客户printf("\n没有匹配的信息");system("pause");
}
void ViewName(char name[], List L)//姓名
{int f = 0;Position p = L->next;while (p){if (strstr(p->name, name)){PrintClient(p);f = 1;}p = p->next;}if (f == 0) //判断是否存在该客户printf("\n没有匹配的信息");system("pause");
}
void ViewTel(char tel[], List L)//电话
{Position p = L->next;int f = 0;while (p){if (strstr(p->tel, tel)){PrintClient(p);f = 1;}p = p->next;}if (f == 0) //判断是否存在该客户printf("\n没有匹配的信息");system("pause");
}
void ViewID(char ID[], List L)//身份证号
{Position p = L->next;int f = 0;while (p){if (strstr(p->ID, ID)){PrintClient(p);f = 1;}p = p->next;}if (f == 0) //判断是否存在该客户printf("\n没有匹配的信息");system("pause");
}
void ViewCom(List L)//综合查询
{Position p = L->next;char name[10], tel[12];printf("输入姓名: \n");gets(name);printf("请输入电话: \n");gets(tel);int f = 0;while (p){if (strcmp(p->name, name) == 0 && strcmp(p->tel, tel) == 0){PrintClient(p);f = 1;}p = p->next;}if (f == 0) //判断是否存在该客户printf("\n没有匹配的信息");system("pause");
}
//收支记录查询
void ViewName1(char name[], List1 L)//按姓名查询
{int f = 0;Position1 p = L->next;gets(name);while (p) //判断P的Next指针是否为空,且P的下一个结点的客户账号是否为查找账号{if (strstr(p->name, name) == 0){PrintRecords(p);f = 1;}p = p->next;}if (f == 0) //判断是否存在该客户printf("\n没有匹配的信息");system("pause");
}
void ViewNum1(char num[], List1 L)//按账号查询
{int f = 0;Position1 p = L->next;while (p) //判断P的Next指针是否为空,且P的下一个结点的客户账号是否为查找账号{if (strstr(p->num, num)){PrintRecords(p);f = 1;}p = p->next;}if (f == 0)printf("\n没有匹配的信息");system("pause");
}
void ViewCom1(List1 L)//综合查询
{Position1 p = L->next;char num[30], time[12];printf("输入账号: \n");gets(num);printf("请输入操作时间: \n");gets(time);int f = 0;while (p){if (strcmp(p->num, num) == 0 && strstr(p->time, time) != NULL){PrintRecords(p);f = 1;}p = p->next;}if (f == 0) //判断是否存在该客户printf("\n没有匹配的信息");system("pause");
}
//排序函数(升序
List SortMoney(List L)//余额(客户信息
{Position a, b, p = L->next;int i, j, num = 0;while (p){num++;p = p->next;}for (j = 0; j < num - 1; j++){a = L->next;b = a->next;p = L;for (i = 0; i < num - 1 - j; i++){if (a->money < b->money){a->next = b->next;p->next = b;b->next = a;}p = p->next;a = p->next;b = a->next;}}Save(L);BianliList(L);return L;
}
List SortNum(List L)//账号(客户信息
{Position a, b, p = L->next;int i, j, num = 0;while (p){num++;p = p->next;}for (j = 0; j < num - 1; j++){p = L;a = L->next;b = a->next;for (i = 0; i < num - 1 - j; i++){if (strcmp(a->num, b->num)>0){a->next = b->next;p->next = b;b->next = a;}p = p->next;a = p->next;b = a->next;}}Save(L);BianliList(L);return L;
}
List1 SortNum1(List1 L)//账号(收支记录
{Position1 a, b, p = L->next;int i, j, num = 0;while (p){num++;p = p->next;}for (j = 0; j < num - 1; j++){p = L;a = L->next;b = a->next;for (i = 0; i < num - 1 - j; i++){if (strcmp(a->num, b->num)>0){a->next = b->next;p->next = b;b->next = a;}p = p->next;a = p->next;b = a->next;}}Save1(L);BianliList1(L);return L;
}
List1 SortTime1(List1 L)//余额(收支记录
{Position1 a, b, p = L->next;int i, j, num = 0;while (p){num++;p = p->next;}for (j = 0; j < num - 1; j++){a = L->next;b = a->next;p = L;for (i = 0; i < num - 1 - j; i++){if (strcmp(a->time, b->time)>0){a->next = b->next;p->next = b;b->next = a;}p = p->next;a = p->next;b = a->next;}}Save1(L);BianliList1(L);return L;
}
//查询修改
void CircleName(char name[], Position p, List L, List1 L1)//姓名
{system("cls");while (p) //判断P的Next指针是否为空,且P的下一个结点的客户电话是否为查找账号{if (strcmp(name, p->name) == 0){PrintClient(p);printf("\n是否是您想修改的账户:回复'Y'/'N'\n");if (getchar() == 'Y'){char a[20];strcpy(a, p->password);Mimayincan(a);ModMeun1(p, L, L1);}else if (getchar() == 'N')CircleName(name, p->next, L, L1);}p = p->next;if (!p){printf("\n该账号不存在: ");system("pause");}}
}
void CircleID(char ID[], Position p, List L, List1 L1)//身份证
{system("cls");while (p) //判断P的Next指针是否为空,且P的下一个结点的客户电话是否为查找账号{if (strcmp(ID, p->ID) == 0){PrintClient(p);printf("\n是否是您想修改的账户:回复'Y'/'N'\n");if (getchar() == 'Y'){char a[20];strcpy(a, p->password);Mimayincan(a);ModMeun1(p, L, L1);}else if (getchar() == 'N')CircleID(ID, p->next, L, L1);}p = p->next;if (!p){printf("\n该账号不存在: ");system("pause");}}
}
void CircleTel(char tel[], Position p, List L, List1 L1)//电话
{system("cls");while (p) //判断P的Next指针是否为空,且P的下一个结点的客户电话是否为查找账号{if (strcmp(tel, p->tel) == 0){PrintClient(p);printf("\n是否是您想修改的账户:回复'Y'/'N'\n");if (getchar() == 'Y'){char a[20];strcpy(a, p->password);Mimayincan(a);ModMeun1(p, L, L1);}else if (getchar() == 'N')CircleTel(tel, p->next, L, L1);}p = p->next;if (!p){printf("\n该账号不存在: ");system("pause");}}
}
//修改函数
void ModName(Position p, List L, List1 L1)//姓名
{char name[10];Position1 p1 = L1->next;Position p2 = L->next;printf("\n请输入新的姓名: ");gets(name);while (p2){if (strcmp(p->ID, p2->ID) == 0){strcpy(p2->name, name);Save(L);}p2 = p2->next;}while (p1){if (strcmp(p->ID, p1->ID) == 0){strcpy(p1->name, name);Save1(L1);}p1 = p1->next;}system("pause");
}
void ModTel(Position p, List L)//电话
{char tel[20];printf("\n请输入新的电话号: ");gets(tel);strcpy(p->tel, tel);Save(L); //调用信息保存函数system("pause");
}
void ModPassword(Position p, List L)//密码
{char a[20];printf("\n请输入新的密码: ");gets(a);strcpy(p->password, a);Save(L);system("pause");
}/********************************功能函数定义******************************************/
Position Logon(List L)//登录函数
{char password[20], num[30], a[5] = "正常", b[5] = "锁定", c[5] = "挂失";//密码,账号int f;printf("\n\t\t请输入您的账号: ");gets(num);Position p = L->next;while (p != NULL && strcmp(num, p->num) != 0)p = p->next;if (!p){printf("\n\t\t该账号不存在!");system("pause");return NULL;}if (strcmp(p->sd, b) == 0){printf("\n\t\t该账号已被锁定,请到柜台解锁!");system("pause");return NULL;}if (strcmp(p->sd, c) == 0){printf("\n\t\t该账号以被挂失,请到柜台取消挂失!");system("pause");return NULL;}strcpy(password, p->password);if (strcmp(p->sd, a) == 0)f = Mimayincan(password);if (f == 1)return p;else{printf("\n\t\t该账号已被锁定,请到柜台解锁!\n");strcpy(p->sd, b); Save(L);system("pause");return NULL;}
}
int Mimayincan(char a[])//密码隐藏函数//退格不删*
{int i, j = 0, flag = 0;char b[20];int n = strlen(a);while (j < 3){printf("\n\t\t请输入您的密码(少于20位):");for (i = 0; i < n; i++){b[i] = getch();if (i>0 && b[i] == '\b'){i = i - 2;printf("\b");}elseprintf("*");}b[i] = '\0';j++;if (strncmp(a, b, n) == 0)return 1;else if (j < 3)printf("\n\t\t密码错误,请重新输入\n\a");else if (flag == 0){printf("\n\t\t抱歉,该账号暂时已被锁定\n");return 0;}}return 1;
}
void PrintClient(Position p)//客户信息打印函数
{printf("\n客户信息如下:\n");printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");printf("账号\t\t\t姓名\t\t电话 \t\t办卡地址\t\t余额\t\t状态\n");printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");printf("%-20s\t%-10s\t%-11s\t%-20s\t%-20.2lf\t\t%-5s\n", p->num, p->name, p->tel, p->loc, p->money, p->sd);printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");
}
void PrintRecords(Position1 p)//收支记录打印函数
{printf("\n\t\t\t\t收支记录如下:\n");printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");printf("账号\t\t\t姓名\t\t操作日期\t\t存取款 \n");printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");printf("%-20s\t%-10s\t%-18s\t%-.2lf \n", p->num, p->name, p->time, p->rmb);printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");
}
int Testl(int a, int b, int c)//菜单输入检测函数
{while (a<b || a>c){fflush(stdin); //清除键盘缓冲区printf("\n\t\t\t输入错误,请重新输入: ");scanf("%d", &a);}return a;
}
void jieshuo(List L, List1 L1)
{char ID[20], num[30], a[5] = "正常", c[5] = "挂失";int x;Position p = L->next;Position1 p1 = L1->next;printf("\n\t\t请输入您要选择的操作:1.解锁账号 2.账号挂失 3.取消挂失 0.返回上一层");printf("\n\n\t\t请输入您的选择:\n");while (1){scanf("%d", &x);x = Testl(x, 0, 9);fflush(stdin); //清除键盘缓冲区switch (x){case 1: printf("\n\t\t请输入您需要解锁的账号:");gets(num);while (p != NULL && strcmp(num, p->num) != 0)p = p->next;if (!p){printf("\n\t\t该账号不存在");system("pause"); return;}else if (strcmp(p->sd, a) == 0){printf("\n\t\t该账号未被锁定");system("pause"); return;}printf("\n\t\t请输入您的身份证号: ");//确认身份信息gets(ID);if (strcmp(ID, p->ID) == 0){strcpy(p->sd, a); Save(L);ModPassword(p, L);}while (p1)//修改收支记录信息{if (strcmp(p->num, p1->num) == 0){strcpy(p1->sd, a);Save1(L1);}p1 = p1->next;}MainMeun1(L, L1); break;case 2: printf("\n\t\t请输入您需要挂失的账号:");gets(num);while (p != NULL && strcmp(num, p->num) != 0)p = p->next;if (!p){printf("\n\t\t该账号不存在");system("pause"); return;}else if (strcmp(p->sd, c) == 0){printf("\n\t\t该账号已挂失");system("pause"); return;}printf("\n\t\t请输入您的身份证号: ");//确认身份信息gets(ID);if (strcmp(ID, p->ID) != 0){printf("\n\t\t身份证输入有误!");system("pause"); return;}Mimayincan(p->password);strcpy(p->sd, c); Save(L);while (p1)//修改收支记录的信息{if (strcmp(p->num, p1->num) == 0){strcpy(p1->sd, c);Save1(L1);}p1 = p1->next;}MainMeun1(L, L1); break;case 3: printf("\n\t\t请输入您需要取消挂失的账号:");gets(num);while (p != NULL && strcmp(num, p->num) != 0)p = p->next;if (!p){printf("\n\t\t该账号不存在");system("pause"); return;}else if (strcmp(p->sd, a) == 0){printf("\n\t\t该账号未挂失");system("pause"); return;}printf("\n\t\t请输入您的身份证号: ");//确认身份信息gets(ID);if (strcmp(ID, p->ID) != 0){printf("\n\t\t身份证输入有误!");system("pause"); return;}Mimayincan(p->password);strcpy(p->sd, a); Save(L);while (p1)//修改收支记录的信息{if (strcmp(p->num, p1->num) == 0){strcpy(p1->sd, a);Save1(L1);}p1 = p1->next;}MainMeun1(L, L1); break;case 0: MainMeun1(L, L1); break;//返回上一层}}
}
**
银行管理系统(c链表实现)相关推荐
- C语言期末作业(15个)-货物管理系统、歌曲信息管理系统、职工信息管理系统源码、学生打卡系统、小学生计算机辅助教学系统、门禁系统、银行管理系统等等
C语言期末作业15个(下) 9.C语言货物管理系统 10.C语言歌曲信息管理系统 11.C语言职工信息管理系统源码 12.C语言学生打卡系统 13.C语言小学生计算机辅助教学系统 14.C语言门禁系统 ...
- 使用类的银行管理系统的C ++程序
In this program, we are using the concept of C++ class and object, following basic operations are be ...
- Python基础项目实践之:面向对象方法实现模拟银行管理系统
Python课堂基础实践系列: Python基础项目实践之:学生信息管理系统 python基础项目实践之: 学生通讯录管理系统 Python基础项目实践之:面向对象方法模拟简单计算器 Python基础 ...
- c语言用链表写管理系统程序,c语言课程设计职工信息管理系统单链表实现程序源代码-20210401015126.docx-原创力文档...
文档编制序号:[KKIDT-LLE0828-LLETD298-POI08] 文档编制序号:[KKIDT-LLE0828-LLETD298-POI08] C语言课程设计职工信息管理系统单链表实现程序源代 ...
- java 银行管理系统怎么储存账户信息_银行管理系统 实现用户注册 登录 存、取款 交易记录查询和修改用户信息等功能...
========= 项 目 介 绍======== 银行账户管理系统 本项目主要实现用户注册 登录 存.取钱和修改用户信息功能. 用户信息的存储和获取通过集合和IO输入输出流实现. 存钱 ...
- 简单的银行管理系统(接口)
简单的银行管理系统(接口) 本例要求实现银行卡系统的银联接口,详细要求如下: 银联接口,用于描述银联统一制定的规则,该接口提供检测密码方法.取钱方法以及查询余额方法. 工商银行接口,用于描述工商银行发 ...
- 银行管理系统(使用SQL Server)-Python快速编程入门(第2版)-人民邮电出版社-阶段案例
阶段案例-银行管理系统 题目描述 银行管理系统是一个集开户.查询.取款.存款.转账.锁定.解锁.退出等一系列业务于一体的管理系统,随着计算机技术在金融行业的广泛应用,银行企业采用管理系统替代了传统手工 ...
- 图书管理系统 (单链表实现,C++及文件操作,超详细)
大家好!这里是小张,五一即将到来,小张在这里提前祝大家劳动节快乐!那么今天小张给大家带来的是由单链表,C++以及文件操作实现的图书信息管理系统. 另外有很多小伙伴们在学习算法的时候,只 ...
- 简单的银行管理系统(功能齐备)
简单的银行管理系统(功能齐备) 我们直接上功能代码.(一个系统中最难的莫过于实现其特有功能) 1--------用户注册或者管理员注册 private static void UserZhuce(Ar ...
- JAVA简单的银行管理系统
账户类 package Account;public abstract class Account {private int id;//账号private String password;//密码pr ...
最新文章
- 2021年大数据Spark(三十九):SparkStreaming实战案例四 窗口函数
- windows server 2003上安装mysql的问题
- jmetter持续时间_Jmeter常用线程组设置及场景运行时间计算
- 阿里云服务器ECS按ctrl+alt+delete无法登录
- h5启动原生APP总结
- mysql 检查点_my05_mysql检查点简述
- PHP使用SMTP邮件服务器
- jq之$(“*“)隐藏所有元素
- 【Kafka】Kafka The valid options based on currently configured listeners are PLAINTEXT,SSL
- 在OS X 10.9上安装Java(Mavericks)
- JDBC工具类DataSourceUtils,dao接口代码示例;
- 微信小程序scroll-view横向滚动
- iOS14 UIDatePicker的变化
- c语言游戏小型程序代码,C语言小游戏源码
- 您没有权限访问网络计算机,Win7提示“无法访问您可能没有权限使用网络资源”如何解决?...
- 【B-分子】2020上海高校程序设计竞赛暨第18届上海大学程序设计联赛夏季赛(同步赛)
- Python 之心有猛虎,细嗅蔷薇
- html 让页脚始终底部,CSS + DIV 让页脚始终保持在页面底部
- 华为设备DNS配置命令
- 度金互联网金融社区:P2P网贷资金必须托管 监管脚步渐响