#include "stdio.h" #include "stdlib.h" #include "string.h" #include "time.h" int menu(); int open();//开户 int save();//存钱 int take();//取钱 int check();//查询 int exchange();//转账 int getacc(int acc,float money);//接收转账 int login();//登录 int print(int count);//打印 int randopen();//生成随机账号 int root() { int i,j; printf("\n\n\n\n\n\n"); printf(" 正在登陆\n"); for(i=0;i<80;i++) { printf("="); } for(i=0;i<80;i++) { printf(">"); for(j=0;j<9000000;j++); } return 0; } int first() { int i,j; char username[5]; char password[10]; printf("\n\n\n\n\n\n\n 请输入柜员用户名:"); scanf("%s",&username); printf(" 请输入登录密码:"); scanf("%s",&password); if(strcmp(username,"hou520")==0&&strcmp(password,"1314520")==0) { printf(" 登录成功"); for(i=0;i<3;i++) { printf("."); for(j=0;j<90000000;j++); } } else { printf(" 帐号或密码错误!\n"); } return 0; } struct { char username[20]; char password[20]; int accont; float money; }person[1000]; int count=0; int main() { system("color 9e"); first(); system("cls"); root(); system("cls"); system("color 9e"); menu(); return 0; } int menu() { int a; do { printf(" ***********************************************\n"); printf(" * *\n"); printf(" * Welcome to the BANK OF YOUMING! *\n"); printf(" * *\n"); printf(" ***********************************************\n"); printf(" 1、开户\n 2、存款\n 3、取款\n 4、查询\n 5、转账\n 6、退出\n"); printf(" 请选择以下操作:"); scanf("%d",&a); system("cls"); switch(a) { case 1:open();break; case 2:save();break; case 3:take();break; case 4:check();break; case 5:exchange();break; case 6:break; default:printf(" 请选择1-6之间的有效选择\n"); } }while(a!=6); return 0; } int randopen() { int i; int open; srand(time(0)); open=rand(); for(i=0;i=0) { person[count].money+=money; printf(" 你存了%d元!\n",money); print(count); } else { printf(" 你的输入有误,请重新输入!\n"); } } return 0; } int take() { float money; int count=login(); if(count!=-1) { printf(" 请输入你的取款数额:"); scanf("%f",&money); if(money>=0&&money<=person[count].money) { person[count].money-=money; printf(" 你取了%d元!\n",money); print(count); } else { printf(" 你的输入有误,请重新输入!\n"); } } return 0; } int check() { int count=login(); if(count!=-1) { print(count); } return 0; } int exchange() { int acc_1,acc_2; float money; int count=login(); if(count!=-1) { printf(" 请输入转账账号:"); scanf("%d",&acc_1); printf(" 请确认对方账号:"); scanf("%d",&acc_2); if(acc_1==acc_2) { printf(" 请输入你要转入的金额:"); scanf("%f",&money); if(money>=0&&money<=person[count].money) { int accCount=getacc(acc_1, money); if(accCount != -1) { printf(" 转账成功!\n"); person[count].money-=money; printf(" 你向对方了%d元!\n",money); } print(count); } } else { printf(" 你的操作有误!\n"); } } return 0; } int getacc(int acc,float money) { int i; for(i=0;i