You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

463 lines
9.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
1、管理员登录
2、存钱
3、取钱
4、注册用户
5、销户
6、挂失
7、用户建议与回馈
8、用户查询
9、所有用户查询
*/
struct USER{
char name[32];
char name_loss[32];
char password[32];
double account_balance;
}user[1000];
void releace_reporting_loss();//解挂 陈小龙
void keeper_enter(); //管理员身份验证 陈小龙
void withdraw_money(); //取钱 欧冲
void save_money(); //存钱 欧冲
void user_account(); //销户 陈小龙
void user_registration(); //开户 欧冲
void reporting_loss(); //挂失 陈小龙
void user_find(); //用户查询 欧冲
void user_total(); //用户总览 陈小龙
void transfer(); //转账 欧冲
void exit_(); //退出 欧冲
void user_feedback(); //用户反馈 陈小龙
int user_name_vf(); //用户名验证 欧冲
int user_password_vf(int); //密码验证 欧冲
int reporting_loss_vf(int); //挂失验证 陈小龙
/*
char user_name[1000][32]; //用户名
char user_password[1000][32]; // 用户密码
char user_name_loss[1000][32];//挂失用户名
double account_balance[1000]; //余额
*/
int user_num=0;//用户数
int user_loss_num=0;//挂失用户数
char feedback_a[1000][1000];
int feedback_num=0; //反馈数
int main(int argc, char *argv[])
{
keeper_enter();
int menu=1; //菜单循环参数
while(menu)
{
printf(" **************************************************************** \n");
printf(" * *\n");
printf(" * <1> 开户 <2> 存款 <3> 取款 *\n");
printf(" * <4> 转账 <5> 查询 <6> 销户 *\n");
printf(" * <7> 挂失 <8> 解挂 <0> 退出 *\n");
printf(" * <9> 查询所有用户信息 <10> 用户反馈 *\n");
printf(" * *\n");
printf(" **************************************************************** \n");
printf("请选择操作选项:");
while(1)
{
scanf("%d",&menu);
if(menu<0||menu>10)
{
printf("请输入正确选项:");
continue;
}
break;
}
switch(menu)
{
case 1: //开户
user_registration();
break;
case 2: //存款
save_money();
break;
case 3: //取款
withdraw_money();
break;
case 4: //转账
transfer();
break;
case 5: //查询
user_find();
break;
case 6: //销户
user_account();
break;
case 7: //挂失
reporting_loss();
break;
case 8: //解挂
releace_reporting_loss();
break;
case 9: //查询所有用户信息
user_total();
break;
case 10: //反馈
user_feedback();
break;
}
}
return 0;
}
void keeper_enter() //管理员身份验证
{
int keeper_enter_pm=1; //登录循环参数
char name1[10];
char password1[20];
printf("**************欢迎进入银行管理系统!!!**************\n");
while(keeper_enter_pm)
{
if(keeper_enter_pm==1)
printf(" ********请先进行管理员验证******** \n");
else
printf("该管理员不存在或者密码错误,请再次验证\n");
printf("*请输入管理员用户名:");
scanf("%s",name1);
printf("*请输入密码:") ;
scanf("%s",password1);
if(strcmp(name1,"1805")==0&&strcmp(password1,"1805")==0)
break;
keeper_enter_pm=2;
}
}
void user_account() //销户
{
int i,n,m;
i=user_name_vf();
m=reporting_loss_vf(i);
if(m==1)
m=user_password_vf(i);
while(m==1)
{
printf("请再次确认是否销户!\n");
printf("(1)确定 2返回");
printf("请输入选项:");
scanf("%d",&n);
if(n==2)
break;
if(n==1)
{
for(;i<user_num;i++)
{
strcpy(user[i].name,user[i+1].name);
strcpy(user[i].password,user[i+1].password);
user[i].account_balance=user[i+1].account_balance;
}
user_num--;
printf("销户成功。\n");
break;
}
}
}
reporting_loss_vf(int i) //挂失验证
{
int j,n;
for(j=0;j<user_loss_num;j++)
{
if(strcmp(user[i].name,user[j].name_loss)==0)
{
printf("此用户已经挂失,请解挂后再进行操作!\n");
n=0;
break;
}
}
if(j==user_loss_num)
n=1;
return n;
}
void reporting_loss() //挂失
{
int i,n,m;
i=user_name_vf();
m=reporting_loss_vf(i);
if(m==1)
m=user_password_vf(i);
while(m==1)
{
printf("请再次确认是否挂失!\n");
printf("(1)确定 2返回");
printf("请输入选项:");
scanf("%d",&n);
if(n==2)
break;
if(n==1)
{
strcpy(user[user_loss_num].name_loss,user[i].name);
user_loss_num++;
printf("用户“%s ”挂失成功。\n ",user[i].name);
break;
}
}
}
void releace_reporting_loss() //解挂
{
int i,n,m,j;
i=user_name_vf();
for(j=0;j<user_loss_num;j++)
{
if(strcmp(user[i].name,user[j].name_loss)==0)
{
//printf("此用户已经挂失,请解挂后再进行操作!\n");
n=0;
break;
}
}
if(n==0)
n=user_password_vf(i);
while(n==1)
{
for(;j<user_loss_num;j++)
strcpy(user[j].name_loss,user[j+1].name_loss);
printf("用户 “%s ” 账户解挂成功!\n",user[i].name);
user_loss_num--;
break;
}
}
void user_total() //用户总览
{
int i;
printf("----------------------------------\n");
for(i=0;i<user_num;i++)
printf("|用户名:%6s | 余额:%6.2f | \n",user[i].name,user[i].account_balance);
printf("----------------------------------\n");
}
int user_name_vf() //用户名验证
{
int i,j=1;
char user1_name[32];
while(j==1)
{
printf("请输入你的用户名:\n");
scanf("%s",user1_name);
for(i=0;i<user_num;i++)
{
if(strcmp(user[i].name,user1_name)==0)
{
j=0;
break;
//printf("fff");
}
if(i==user_num-1)
{
printf("你输入的用户名有误,");
}
}
}
return i;
}
int user_password_vf(int i) //密码验证
{
char user1_password[32];
int m=5;
while(m--)
{
printf("请输入你的用户密码:\n");
scanf("%s",user1_password);
if(strcmp(user[i].password,user1_password)==0)
{
printf("登陆成功!\n");
printf("用户名:%s\n目前余额:%.2lf\n",user[i].name,user[i].account_balance);
break;
}else{
printf("你输入的密码有误\n");
}
}
if(m==(-1))
return 0;
else
return 1;
}
void user_find() //用户查询
{
int i,n;
i=user_name_vf();
n=reporting_loss_vf(i);
if(n==1)
{
n=user_password_vf(i);
}
}
void exit_() //退出
{
}
void user_registration() //用户注册
{
char user1_name[32],user1_password[32],user2_password[32];
int i,user1_num=user_num,j=0;
double money;
while(1){
j=0;
printf("请输入你要创建的用户名:\n");
getchar();
scanf("%s",user1_name);
for(i=0;i<user_num+1;i++)
{
if(strcmp(user1_name,user[i].name)==0)
{
printf("你所输入的用户名已存在!\n");
break;
}
else{
strcpy(user[user_num].name,user1_name);
while(j==0)
{
printf("请输入密码:\n");
scanf("%s",user1_password);
printf("请再次输入密码:\n");
scanf("%s",user2_password);
if(strcmp(user1_password,user2_password)!=0)
{
printf("两次输入密码有误,请重新输入!\n");
}else{
strcpy(user[user_num].password,user1_password);
printf("密码设置成功!\n请输入你的存款金额:\n");
scanf("%lf",&money);
user[user_num].account_balance=money;
j=1;
}
}
user_num++;
break;
}
}
break;
}
}
void save_money() //存钱
{
int i,n;
double money;
i=user_name_vf();
n=reporting_loss_vf(i);
if(n==1)
{
n=user_password_vf(i);
}
while(n==1)
{
printf("请输入你存款金额:\n");
scanf("%lf",&money);
user[i].account_balance=user[i].account_balance+money;
printf("此次存款成功!\n当前余额为:%.2lf\n",user[i].account_balance);
break;
}
}
void withdraw_money() //取钱
{
int i,n;
double money;
i=user_name_vf();
n=reporting_loss_vf(i);
if(n==1)
{
n=user_password_vf(i);
}
if(n==1)
{
printf("请输入你取款金额:\n");
scanf("%lf",&money);
if(money>user[i].account_balance)
{
printf("你的余额不足以支持此次取款!\n请重新输入取款金额:\n");
}else{
user[i].account_balance=user[i].account_balance-money;
printf("此次取款成功!\n当前余额为:%.2 lf\n",user[i].account_balance);
}
}
}
void user_feedback() //用户反馈
{
int menu1,e;
printf("菜单:\n");
printf("<1>反馈 <2>查询反馈\n");
printf("请选择指令:");
scanf("%d",&menu1);
if(menu1==1)
{
printf("请写下您宝贵的意见:\n");
scanf("%s",feedback_a[feedback_num]);
feedback_num++;
}
if(menu1==2)
{
for(e=0;e<feedback_num;e++)
{
printf("%d.%s",e+1,feedback_a[e]);
printf("\n");
}
}
}
void transfer() //转账
{
int i,n=1,j,s=1,m;
double f_money;
char user1_name[32];
i=user_name_vf();
m=reporting_loss_vf(i);
if(m==1)
m=user_password_vf(i);
while(m==1)
{
printf("请输入目标账户:");
scanf("%s",user1_name);
for(j=0;j<user_num;j++)
{
if(strcmp(user[j].name,user1_name)==0)
{
m=2;
break;
}
}
if(j==user_num)
printf("目标账户不存在,请重新输入。\n");
}
while(m==2)
{
printf("请输入转账金额:");
scanf("%lf",&f_money);
if(f_money<=user[i].account_balance)
{
user[i].account_balance=user[i].account_balance-f_money;
user[j].account_balance=user[j].account_balance+f_money;
printf("转账成功!\n您的当前余额为: %.2f\n",user[i].account_balance);
break;
}
else
printf("余额不足,请重新输入。\n");
}
}