一、头文件
#pragma once
//预处理指令 防止头文件被重复引用
#ifndef _INC_BANK
#define _INC_BANK
#define DATESIZE 30 //日期长度
#define NAMESIZE 20 //名字长度
#define INITMSIZE 5 //管理员个数
#define INITCSIZE 20 //银行卡 初始个数
#define ERRTIMES 3 //密码错误次数 3 锁
#define LIMIT 1000 //日取款上限
#define RECORDSIZE 50 //初始化记录容量
#define True 1
#define False 0
typedef int BOOL;
//设计管理员 -- 身份
enum Identity { ordinary, super };
typedef struct Manager
{
int _mid; //管理员账号
int _mpasswd; //管理员密码
int _merrtimes; //当前管理员登录失败次数
BOOL _mislocked; //状态
enum Identity _identity; //管理员身份
}Manager;
typedef struct User
{
char _name[NAMESIZE]; //姓名
char _idcard[20];
long long _phone;
}User;
typedef struct BankMessage
{
char _bankname[NAMESIZE];
char _address[NAMESIZE];
}BankMessage;
typedef struct Record
{
char _rtime[DATESIZE]; //什么时间
char _rtype[10]; // 存款 取款 转入 转出
float _rmoney; //取: -100 存 100
}Record;
//不定长顺序表
typedef struct RecordArray
{
Record* _precords; //当办卡 卡属性初始化 对卡流水明细数组malloc
int _rsize; //记录有效条数
int _rcapacity; //记录容量 不足 扩容
}RecordArray;
//银行卡
typedef struct BankCard
{
int _cid;
int _cpasswd;
float money;
int _cerrtimes; //银行卡登录失败次数
int _daylimit; //日取款上限
BOOL _cislocked;
char _createdate[DATESIZE]; //2024-1-16 星期三 16:24:30
//流水明细 -- 很多条什么时间 什么事情 涉及金额
RecordArray _recordarr;//[][][][][][] size capacity
//储户信息
User _user;
//银行信息
BankMessage _bankmessage;
}BankCard;
//银行系统 存一堆卡 一堆管理员
struct CardArray
{
BankCard* _pcards; //卡数组 不定长顺序表结构
int _csize;
int _ccapacity;
};
struct ManagerArray
{
Manager _managers[INITMSIZE]; //卡数组 定长顺序表
int _msize;
};
struct BankSystem
{
CardArray carray;
ManagerArray marray;
};
//功能:
//初始化银行系统: 将银行中数据 -- 给定一个超级管理员信息
void InitBankSys(BankSystem* sys);
//管理员登陆 改返回值************
Manager* MLogin(ManagerArray* pmarr, int id, int passwd, enum Identity identity);
//管理员注册
BOOL MRegister(ManagerArray* pmarr, int id, int passwd, enum Identity identity);
//根据账号,密码删除管理员
BOOL MDelete(ManagerArray* pmarr, int id, int passwd);
//激活管理员 ---冻结管理员 _mislocked = false true
//激活 某个管理员 账号激活
BOOL MSetLockedState(ManagerArray* pmarr, int mid, BOOL state);
BOOL ChangerMPasswd(Manager* pm, int newpasswd);
BankCard* SearchByIdCard(CardArray* pcarr, const char* idcard);
//办卡
void CreateCard(CardArray* pcarr);
//注销卡
BOOL DeleteCard(CardArray* pcarr, const char* idcard);
//激活 挂失
BOOL CSetLockedState(CardArray* pcarr, const char* idcard, BOOL state);
//查看开卡日期
void GetCreateDate(BankCard* pcard);
//查看流水明细
void GetWaterRecord(BankCard* pcard);
//查询 收支情况 1. 3个月 2. 6个月 3.1年
void GetMoneyMessage(BankCard* pcard);
//卡登录
BankCard* CLogin(CardArray* pcarr, int id, int passwd);
BOOL SaveMoney(BankCard* pc, float money);
BOOL Withdraw(BankCard* pc, float money); //余额 日取款上限
void GetMoney(BankCard* pc);
BOOL Transfer(BankCard* pc, CardArray* parr, int userid, float money);
BOOL ChangeCPasswd(BankCard* pc, int newpasswd);
Manager* MSearchById(ManagerArray* pmarr, int id);
#endif // !_INC_BANK
二、函数实现
#define _CRT_SECURE_NO_WARNINGS
#include"bank.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <cassert>
#include <time.h>
const char* week[] = { "星期日","星期一","星期二","星期三","星期四" ,"星期五" ,"星期六" };
// 功能:
//初始化银行系统: 将银行中数据 -- 给定一个超级管理员信息
void InitBankSys(BankSystem* sys)
{
assert(sys != NULL);
sys->carray._pcards = (BankCard*)malloc(INITCSIZE * sizeof(BankCard));
assert(sys->carray._pcards != NULL);
sys->carray._csize = 0; //有效数据个数0
sys->carray._ccapacity = INITCSIZE;
printf("银行卡数组信息初始化成功\n");
//账号,密码 =0 次数 islocked=FALSE managers[0]
memset(&sys->marray._managers[0], 0, sizeof(Manager));
sys->marray._managers[0]._identity = super; //超级管理员
// sys->marray._managers
sys->marray._msize = 1;
printf("管理员数组信息初始化成功\n");
}
//静态函数 --- 无链接属性 外文本无法链接当前静态函数
Manager* MSearchById(ManagerArray* pmarr, int id)
{
for (int i = 0; i < INITMSIZE; i++)
{
if (pmarr->_managers[i]._mid == id)
{
return pmarr->_managers + i;
//return &pmarr->_managers[i];
}
}
return NULL;
}
//管理员登陆 --- 元素查找
Manager* MLogin(ManagerArray* pmarr, int id, int passwd, enum Identity identity)
{
assert(pmarr != NULL);
Manager* pm = (Manager*)MSearchById(pmarr, id);
if (pm == NULL) { printf("不存在该账号,登录失败\n"); return False; }
if (pm->_mpasswd == passwd && !pm->_mislocked && pm->_identity == identity)
{
printf("登录成功\n");
return pm;
}
if (pm->_mpasswd != passwd && pm->_merrtimes < ERRTIMES)
{
printf("密码错误%d次\n", pm->_merrtimes + 1);
if (++pm->_merrtimes == ERRTIMES)
{
pm->_mislocked = True;
printf("账号为:%d 的管理员身份已被锁,请激活\n", id);
return NULL;
}
}
if (pm->_identity != identity)
{
printf("身份不符,登录失败\n");
}
else
{
printf("账号为:%d的管理员身份已被锁,登录失败\n", id);
}
//锁管理员
return NULL;
}
//管理员注册 -- 账号不重复 尾插 有效数据 后 数据存储 [][val][][] msize=1
BOOL MRegister(ManagerArray* pmarr, int id, int passwd, enum Identity identity)
{
assert(pmarr != NULL);
// 内存是否已满
if (pmarr->_msize == INITMSIZE)
{
printf("岗位已满,注册失败\n");
return False;
}
//找是否有账号重复 若 有 注册失败
Manager* pm = (Manager*)MSearchById(pmarr, id);
if (pm != NULL) { printf("账号已重复,注册失败\n"); return False; }
//若没有重复
pmarr->_managers[pmarr->_msize]._mid = id;
pmarr->_managers[pmarr->_msize]._mpasswd = passwd;
pmarr->_managers[pmarr->_msize]._identity = identity;
pmarr->_managers[pmarr->_msize]._merrtimes = 0;
pmarr->_managers[pmarr->_msize]._mislocked = False;
pmarr->_msize++;
printf("注册成功\n");
return True;
}
//根据账号,密码删除管理员
BOOL MDelete(ManagerArray* pmarr, int id, int passwd)
{
assert(pmarr != NULL);
//找到管理员信息
Manager* pm = (Manager*)MSearchById(pmarr, id);
if (pm == NULL) { printf("不存在该账号,删除失败\n"); return False; }
//将管理员删除
/*memmove(pm,pm+1,(pmarr->_msize-(pm - pmarr->_managers)-1)*sizeof(Manager));
pmarr->_msize--;*/
int i = pm - pmarr->_managers; //待删元素下标
for (int j = i + 1; j < pmarr->_msize; j++)
{
pmarr->_managers[j - 1] = pmarr->_managers[j];
}
pmarr->_msize--;
printf("删除账号为:%d 管理员成功\n", id);
return True;
}
//激活管理员 ---冻结管理员 _mislocked = false true
//激活 某个管理员 账号激活
BOOL MSetLockedState(ManagerArray* pmarr, int mid, BOOL state)
{
assert(pmarr != NULL);
Manager* pm = (Manager*)MSearchById(pmarr, mid);
if (pm == NULL) { printf("不存在该账号,状态修改失败\n"); return False; }
pm->_mislocked = state;
printf("状态设置成功\n");
return True;
}
BOOL ChangerMPasswd(Manager* pm, int newpasswd)
{
assert(pm != NULL);
pm->_mpasswd = newpasswd;
printf("密码修改成功\n");
return True;
}
static BOOL Grow(CardArray* pcarr)
{
int newlen = pcarr->_ccapacity * 2;
BankCard* tmp = (BankCard*)realloc(pcarr->_pcards, newlen * sizeof(BankCard));
if (tmp == NULL) return False;
pcarr->_pcards = tmp;
pcarr->_ccapacity = newlen;
return True;
}
static void GetSystemTime(char* buff)
{
time_t t = time(NULL);
tm* ptm = localtime(&t); //2024-1-23 星期二 15:23:50
sprintf(buff, "%d-%d-%d %s %d:%d:%d",
ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday,
week[ptm->tm_wday], ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
}
static BOOL GrowRecords(BankCard* pc)
{
Record* tmp = (Record*)realloc(pc->_recordarr._precords, 2 * pc->_recordarr._rcapacity * sizeof(Record));
if (tmp == NULL) return False;
pc->_recordarr._precords = tmp;
pc->_recordarr._rcapacity *= 2;
return True;
}
static void InsertRecord(BankCard* pc, const char* time, const char* type, float money)
{
RecordArray* prarr = &pc->_recordarr;
if (prarr->_rsize == prarr->_rcapacity && !GrowRecords(pc))
{
printf("内存不足,记录扩容失败\n");
return;
}
prarr->_precords[prarr->_rsize]._rmoney = money;
strcpy(prarr->_precords[prarr->_rsize]._rtime, time);
strcpy(prarr->_precords[prarr->_rsize]._rtype, type);
prarr->_rsize++;
}
BankCard* SearchByIdCard(CardArray* pcarr, const char* idcard)
{
for (int i = 0; i < pcarr->_csize; i++)
{
if (strcmp(pcarr->_pcards[i]._user._idcard, idcard) == 0)
{
return pcarr->_pcards + i;
}
}
return NULL;
}
//办卡 --- 注册卡 pcarr->[][][][][][][] csize 下标存放数值 csize++
//扩展 身份证不能重复
void CreateCard(CardArray* pcarr)
{
assert(pcarr != NULL);
//1.扩容
if (pcarr->_csize == pcarr->_ccapacity && !Grow(pcarr))
{
printf("扩容失败,内存溢出\n");
return;
}
//2. csize下标存储值
char idcard[20];
printf("请输入储户名:"); scanf("%s", pcarr->_pcards[pcarr->_csize]._user._name);
printf("请输入储户身份证号:"); scanf("%s", idcard);
if (SearchByIdCard(pcarr, idcard) != NULL) //身份证号重复
{
printf("身份证号已重复,请重新注册\n");
return;
}
strcpy(pcarr->_pcards[pcarr->_csize]._user._idcard, idcard);
printf("请输入储户电话:"); scanf("%lld", &pcarr->_pcards[pcarr->_csize]._user._phone);
printf("请输入账号:"); scanf("%d", &pcarr->_pcards[pcarr->_csize]._cid);
printf("请输入密码:"); scanf("%d", &pcarr->_pcards[pcarr->_csize]._cpasswd);
printf("请输入储存金额:"); scanf("%f", &pcarr->_pcards[pcarr->_csize].money);
pcarr->_pcards[pcarr->_csize]._cerrtimes = 0;
pcarr->_pcards[pcarr->_csize]._cislocked = False;
pcarr->_pcards[pcarr->_csize]._daylimit = LIMIT;
GetSystemTime(pcarr->_pcards[pcarr->_csize]._createdate);
printf("请输入银行名:"); scanf("%s", pcarr->_pcards[pcarr->_csize]._bankmessage._bankname);
printf("请输入银行地址:"); scanf("%s", pcarr->_pcards[pcarr->_csize]._bankmessage._address);
RecordArray* prarr = &pcarr->_pcards[pcarr->_csize]._recordarr;
prarr->_precords = (Record*)malloc(RECORDSIZE * sizeof(Record));
assert(prarr->_precords != NULL);
prarr->_rsize = 0;
prarr->_rcapacity = RECORDSIZE;
//插入办卡流水记录 哪张卡 什么事情 什么时间 钱
InsertRecord(&pcarr->_pcards[pcarr->_csize],
pcarr->_pcards[pcarr->_csize]._createdate,
"办卡",
pcarr->_pcards[pcarr->_csize].money);
//3. csize++
pcarr->_csize++;
printf("办卡成功\n");
}
//注销卡
BOOL DeleteCard(CardArray* pcarr, const char* idcard)
{
BankCard* pc = SearchByIdCard(pcarr, idcard);
if (pc == NULL)
{
printf("注销失败\n");
return False;
}
free(pc->_recordarr._precords); //释放当前卡 额外动态内存
for (int j = pc - pcarr->_pcards + 1; j < pcarr->_csize; j++)
{
pcarr->_pcards[j - 1] = pcarr->_pcards[j];
}
pcarr->_csize--;
printf("注销成功\n");
return True;
}
//激活 挂失
BOOL CSetLockedState(CardArray* pcarr, const char* idcard, BOOL state)
{
BankCard* pc = SearchByIdCard(pcarr, idcard);
if (pc == NULL) { printf("不存在该用户\n"); return False; }
pc->_cislocked = state;
printf("修改状态成功\n");
return True;
}
//查看开卡日期
void GetCreateDate(BankCard* pcard)
{
printf("%s\n", pcard->_createdate);
}
//查看流水明细
void GetWaterRecord(BankCard* pcard)
{
printf("序号\t时间\t事情\t金额\n");
for (int i = 0; i < pcard->_recordarr._rsize; i++)
{
printf("%d\t%s\t%s\t%f\n", i + 1, pcard->_recordarr._precords[i]._rtime,
pcard->_recordarr._precords[i]._rtype,
pcard->_recordarr._precords[i]._rmoney);
}
}
static void GetMessageMonths(BankCard* pcard, int months)
{
//从当前这个月开始向前推时间 money+
float collectmoney = 0, expendmoney = 0; //收 支出
//char buff[DATESIZE]; //年+月+日
//GetSystemTime(buff); //2024-1-27 3个月 2022 - 10 - 27
time_t t = time(NULL);
tm* ptm = localtime(&t); //2024-1-23 星期二 15:23:50
int curmonth = ptm->tm_mon + 1;
int curyear = ptm->tm_year + 1900;
int curday = ptm->tm_mday;
int endday = ptm->tm_mday;//最晚日期2024- 1-27 -----2023- 10-27日
int endyear, endmonth;
if (curmonth - months <= 0) //不在同一年
{
endyear = curyear - 1; //统计前一年的年份
endmonth = 12 + curmonth - months; //12个月+curmonth-months = 终止月份
//2024-1-27 2023-10-27
//遍历记录数组 倒着遍历。从2024-1-27日向前遍历,到2023-10.27终止
}
else //2024-8-23 3个月 2024-5-23
{
endyear = curyear; //当前年
endmonth = curmonth - months;
}
//清楚: 从2024-1-27 2023-10-27
//倒着遍历记录数组 统计年>=2023&& month > "10"
//??????????可以考虑不转化为字符串比较 ?????????????
char endy[5], endm[3]; //整型年 转字符串
char curd[3];
_itoa(endyear, endy, 10); //"2023"
_itoa(endmonth, endm, 10);
_itoa(curday, curd, 10);
char* ryear, * rmonth, * rday; //年月日 记录
for (int i = pcard->_recordarr._rsize - 1; i >= 0; i--)
{
ryear = strtok(pcard->_recordarr._precords[i]._rtime, "-"); //年
rmonth = strtok(NULL, "-"); //月
rday = strtok(NULL, "-"); //2024-1-27 星期六 15:54:50
rday = strtok(rday, " "); //日
if (strcmp(ryear, endy) >= 0
|| strcmp(ryear, endy) == 0 && strcmp(rmonth, endm) == 0 && strcmp(rday, curd) >= 0) //2024 >= 2023
{
if (pcard->_recordarr._precords[i]._rmoney > 0)
{
collectmoney += pcard->_recordarr._precords[i]._rmoney;
}
else
{
expendmoney += pcard->_recordarr._precords[i]._rmoney;
}
}
}
//年==2023 && month == 10 && day>=curday
printf("%d个月的收支情况: 收%f,支%f\n", months, collectmoney, expendmoney);
}
//查询 收支情况 1. 3个月 2. 6个月 3.1年
void GetMoneyMessage(BankCard* pcard)
{
//当前card 流水记录 11 12 1 三个月 收:>0钱累加和 支:<0钱累加和
printf("查询收支情况 : 1.3个月 2.6个月 3. 1年\n");
int choice;
scanf("%d", &choice);
if (choice == 1) GetMessageMonths(pcard, 3);
else if (choice == 2) GetMessageMonths(pcard, 6);
else if (choice == 3) GetMessageMonths(pcard, 12);
}
//卡登录
BankCard* CLogin(CardArray* pcarr, int id, int passwd)
{
assert(pcarr != NULL);
for (int i = 0; i < pcarr->_csize; i++)
{
if (pcarr->_pcards[i]._cid == id && pcarr->_pcards[i]._cpasswd == passwd
&& !pcarr->_pcards[i]._cislocked)
{
printf("登录成功\n");
return &pcarr->_pcards[i];
}
}
printf("登录失败\n");
return NULL;
}
BOOL SaveMoney(BankCard* pc, float money)
{
pc->money += money;
char buff[DATESIZE];
GetSystemTime(buff);
InsertRecord(pc, buff, "存款", money);
return True;
}
BOOL Withdraw(BankCard* pc, float money) //余额 日取款上限
{
if (pc->money >= money && money <= LIMIT)
{
pc->money -= money;
char buff[DATESIZE];
GetSystemTime(buff);
InsertRecord(pc, buff, "取款", -1 * money);
printf("取款成功\n");
return False;
}
printf("取款失败\n");
return False;
}
void GetMoney(BankCard* pc)
{
printf("当前余额: %f\n", pc->money);
}
BOOL Transfer(BankCard* pc, CardArray* pcarr, int userid, float money)
{
BankCard* puser = NULL;
for (int i = 0; i < pcarr->_csize; i++) //找到对方用户
{
if (pcarr->_pcards[i]._cid == userid && !pcarr->_pcards[i]._cislocked)
{
puser = pcarr->_pcards + i;
break;
}
}
if (puser == NULL) { printf("不存在该用户,转账失败\n"); return False; }
char buff[DATESIZE];
GetSystemTime(buff);
if (pc->money >= money)
{
pc->money -= money;
puser->money += money;
InsertRecord(pc, buff, "转出", -1 * money);
InsertRecord(puser, buff, "转入", money);
printf("转账成功\n");
return True;
}
printf("转账失败\n");
return False;
}
BOOL ChangeCPasswd(BankCard* pc, int newpasswd)
{
pc->_cpasswd = newpasswd;
printf("密码修改成功\n");
return True;
}
三、主函数
#define _CRT_SECURE_NO_WARNINGS
#include "bank.h"
#include <stdio.h>
void OrdinaryLoginSuccessOp(BankSystem* sys, Manager* pm)
{
int choice;
char idcard[20];
printf("普通管理员登录成功n");
while (1)
{
printf("1. 办卡 2.销卡 3.挂失 4.激活 5.查看办卡日期 6. 流水明细 7.修改管理员密码 8.查询收支 9.退出 \n");
scanf("%d", &choice);
if (choice == 1)
{
CreateCard(&sys->carray);
}
else if (choice == 2)
{
printf("请输入储户身份证: ");
scanf("%s", idcard);
DeleteCard(&sys->carray, idcard);
}
else if (choice == 3 || choice == 4)
{
printf("请输入储户身份证: ");
scanf("%s", idcard);
BOOL state = choice == 3 ? True : False;
CSetLockedState(&sys->carray, idcard, state);
}
else if (choice == 5)
{
printf("请输入储户身份证: ");
scanf("%s", idcard);
BankCard* pcard = SearchByIdCard(&sys->carray, idcard);
if (pcard == NULL) { printf("查询失败\n"); continue; }
GetCreateDate(pcard);
}
else if (choice == 6)
{
printf("请输入储户身份证: ");
scanf("%s", idcard);
BankCard* pcard = SearchByIdCard(&sys->carray, idcard);
if (pcard == NULL) { printf("查询失败\n"); continue; }
GetWaterRecord(pcard);
}
else if (choice == 7)
{
printf("请输入新密码: ");
int newpasswd; scanf("%d", &newpasswd);
ChangerMPasswd(pm, newpasswd);
}
else if (choice == 8)
{
printf("请输入储户身份证: ");
scanf("%s", idcard);
BankCard* pcard = SearchByIdCard(&sys->carray, idcard);
if (pcard == NULL) { printf("查询失败\n"); continue; }
GetMoneyMessage(pcard);
}
else if (choice == 9)
{
break;
}
}
}
void RootLoginSuccessOp(ManagerArray* pmarr)
{
int choice, id, passwd, num;
enum Identity identity;
Manager* pm;
int newpasswd;
while (1)
{
printf("超级管理员操作\n");
printf("1. 注册管理员 2.管理员销户 3.激活管理员 4.修改密码 5.退出\n");
scanf("%d", &choice);
if (choice == 5) break;
switch (choice)
{
case 1:
printf("请输入账号,密码,身份(1.普通 2.超级)\n");
scanf("%d%d%d", &id, &passwd, &num);
identity = num == 2 ? super : ordinary;
MRegister(pmarr, id, passwd, identity);
break;
case 2:
printf("请输入账号,密码\n");
scanf("%d%d", &id, &passwd);
MDelete(pmarr, id, passwd);
break;
case 3:
printf("请输入账号\n");
scanf("%d", &id);
MSetLockedState(pmarr, id, True);
break;
case 4:
printf("请输入管理员账号: ");
scanf("%d", &id);
pm = MSearchById(pmarr, id);
if (pm == NULL) { printf("不存在该管理员\n"); break; }
printf("请输入新密码: ");
scanf("%d", &newpasswd);
ChangerMPasswd(pm, newpasswd);
default:
break;
}
}
}
void ManagerOp(BankSystem* sys)
{
int choice, id, passwd, num;;
enum Identity identity;
while (1)
{
printf("管理员身份: 1.登录 2.退出\n请选择:");
scanf("%d", &choice);
if (choice == 2) break;
if (choice == 1)
{
printf("请输入账号,密码,身份(1.普通 2.超级)\n");
scanf("%d%d%d", &id, &passwd, &num);
identity = num == 2 ? super : ordinary;
Manager* pm = MLogin(&sys->marray, id, passwd, identity);
if (pm == NULL) break;
if (pm->_identity == ordinary) //普通管理员
{
OrdinaryLoginSuccessOp(sys, pm);
}
else //超级管理员
{
RootLoginSuccessOp(&sys->marray);
}
}
}
}
void CardAfterLoginSuccess(BankCard* pc, CardArray* pcarr)
{
int choice, newpasswd, userid;
float money;
while (1)
{
printf("1.存款 2.取款 3.转账 4.查余额 5.修改密码 6.退出\n");
scanf("%d", &choice);
if (choice == 6) break;
if (choice == 4) GetMoney(pc);
else if (choice == 5)
{
printf("请输入新密码: ");
scanf("%d", &newpasswd);
ChangeCPasswd(pc, newpasswd);
}
else {
printf("请输入金额: ");
scanf("%f", &money);
switch (choice)
{
case 1:
SaveMoney(pc, money);
break;
case 2:
Withdraw(pc, money);
break;
case 3:
printf("请输入对方用户账号: ");
scanf("%d", &userid);
Transfer(pc, pcarr, userid, money);
break;
default:
break;
}
}
}
}
void UserOp(BankSystem* sys)
{
int choice, id, passwd;
while (1)
{
printf("1.登录 2.退出\n");
scanf("%d", &choice);
if (choice == 1)
{
printf("请输入账号,密码: ");
scanf("%d%d", &id, &passwd);
BankCard* pc = CLogin(&sys->carray, id, passwd);
if (pc != NULL)
{
CardAfterLoginSuccess(pc, &sys->carray);
}
}
else if (choice == 2) break;
}
}
int main()
{
BankSystem sys;
InitBankSys(&sys); //结构体内部成员 内存开辟 + 初始化
int choice;
while (1)
{
printf("身份选择: 1.管理员 2.储户 3. 退出\n");
scanf("%d", &choice);
if (choice == 3) break;
if (choice == 1)
{
ManagerOp(&sys);
}
else if (choice == 2)
{
UserOp(&sys);
}
}
return 0;
}