用C语言编银行叫号系统

用C语言编银行叫号系统,第1张

#include "stdafxh"

#include <stdioh>

#include <stdlibh>

#include <timeh>

#include <stringh>

#include <conioh>

#define MAX_SIZE 500

struct tagCustom

{

int m_nID; // 客户的编号

int m_nProcessTime; // 需要处理业务的时间

int m_nArrivalTime; // 到达时间

int m_nDepartTime; // 离开时间

};

struct tagTeller

{

int m_nCustomNum; // 处理的客户数

int m_nAllServiceTime; // 所有服务时间

int m_nFinishServiceTime; // 柜台针对一个客户服务的结束时间

bool m_bBusy; // 柜台是否忙

int m_nCustomID; // 正在服务的客户的ID号

};

tagTeller g_aryTellers[MAX_SIZE];

int g_nTellerNum; // 柜台数量

// 用户到达数组(随机的,无序的)

tagCustom g_aryAllCustoms[MAX_SIZE];

int g_nCustomsNum;

int g_nWorkTime; // 经营时间

int g_nArrivalRange,g_nServiceRange;

// 用户队列

tagCustom g_CustomQueue[MAX_SIZE];

int g_nHeader,g_nTail;

// 队列的 *** 作

void InitQueue()

{

g_nHeader = g_nTail = -1;

}

void AddToTail(tagCustom aCustom)

{

g_nTail++;

g_CustomQueue[g_nTail] = aCustom;

}

bool RemoveFromHeader(tagCustom pCustom)

{

if(g_nHeader < g_nTail)

{

g_nHeader++;

(pCustom) = g_CustomQueue[g_nHeader];

return true;

}

return false;

}

// 功能:模拟用户的随机到来

void GenerateCustom()

{

tagCustom aCustom;

for(int nCounter = 0; nCounter < g_nCustomsNum; nCounter++)

{

aCustomm_nID = nCounter;

aCustomm_nArrivalTime = rand() % g_nWorkTime ;

aCustomm_nProcessTime = (rand() % g_nServiceRange + 1) 6;

aCustomm_nDepartTime = -1;

g_aryAllCustoms[nCounter] = aCustom;

}

}

void Init()

{

g_nTellerNum = 3;

g_nWorkTime = 200;

g_nCustomsNum = 30;

g_nArrivalRange = 18 ;

g_nServiceRange = 5 ;

srand((unsigned)time(NULL));

InitQueue();

GenerateCustom();

for(int nC = 0; nC < g_nTellerNum; nC++)

{

g_aryTellers[nC]m_nAllServiceTime = 0;

g_aryTellers[nC]m_nCustomID = -1;

g_aryTellers[nC]m_bBusy = false;

g_aryTellers[nC]m_nFinishServiceTime = -1;

}

}

功能:能够输入和查询客户存款取款记录。在客户文件中,每个客户是一条记录,包括编号、客户姓名、支取密码、客户地址、客户电话、账户总金额;在存取款文件中,每次存取款是一条记录,包括编号、日期、类别、存取数目、经办人。类别分为取款和存款两种。本系统能够输入客户存款或取款记录;根据客户姓名查询存款和取款记录。分步实施:1、初步完成总体设计,搭好框架,确定人机对话界面,确定函数个数;2、建立一个文件,输入客户的必要信息,能对文件进行显示、输入、修订、删除等。3、进一步要求:完成客户姓名查询存款和取款记录,并能得到每次帐户总金额。要求:1、用C语言实现系统;2、利用结构体数组实现信息的数据结构设计;3、系统的各个功能模块要求用函数的形式实现;4、界面友好(良好的人机交互),程序加必要的注释。课程设计实验报告要求:1、预习报告:题目、课程设计任务、数据结构、程序的总体设计(算法)、模块划分 。2、实验总结报告:流程图、主要源程序代码(需打印)、测试情况及调试中问题与解决方案、小结等要求:标明所用函数的用途和目的,简单叙述制作思路。

是否可以解决您的问题?

简单一点,就定义一个结构类型,包含你上面说的账户信息成员变量。然后根据输入创建链表。

复杂一点使用fopen函数创建或读取已有文件,然后用fscanf函数把你链表中的数据写入到文件中保存。

再复杂一点,就写数据库连接,用数据库保存数据。

#include <conioh>

#include <stringh>

#include <stdioh>

#include <stdlibh>

char cFile[] = "datetxt";

struct bank

{

char id[10+1];

char psw[6+1];

double money;

};

welcome1()

{

printf("\n\n\t\t欢迎使用虚拟银行自动取款机服务!\t\t\n\n");

printf("请选择功能:\n");

printf("\n=================================================\n");

printf(" || 请输入序号 ||\n");

printf(" || 1新用户开户。 ||\n");

printf(" || 2老用户登陆。 ||\n");

printf(" || 3退出系统。 ||\n");

printf("=================================================\n");

}

welcome2()

{

printf("\n\n\t\t注册须知\n\n");

printf("\n");

printf(" 1请填写您的真实资料! \n");

printf(" 2开户首期必须存入100元以上 \n");

printf("\n");

}

welcome3()

{

printf("\n\n\t\t\3 欢迎进入虚拟银行系统 \3\n\n");

printf("\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\n");

printf("\1\1\t 请选择功能:1取款(最多透资2000); \1\1\n");

printf("\1\1\t 2存款; \1\1\n");

printf("\1\1\t 3查询余额; \1\1\n");

printf("\1\1\t 4修改密码; \1\1\n");

printf("\1\1\t 5返回主页面; \1\1\n");

printf("\1\1\t 任意键退出 \1\1\n");

printf("\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\n");

}

int search(char user, char pwd, char real_pwd)/判断帐号是否相同,不相同返回1/

{

FILE file;

char user_buff[256], pwd_buff[256];

file = fopen(cFile, "r");

if (!file) return 0;

while (!feof(file))

{

if (fscanf(file, "%s%s\n", user_buff, pwd_buff) == EOF) return 0;

if (!strcmp(user_buff, user))

{

if (real_pwd) strcpy(real_pwd, pwd_buff);

return 1;

}

}

fclose(file);

return 0;

}

int add(char user, char pwd, double coin_n)

{

FILE file;

file = fopen(cFile, "a");

if (!file) return 0;

fprintf(file, "%s %s %2lf\n", user, pwd, coin_n);

fclose(file);

return 0;

}

int wenjian(char user, char pwd,double coin)

{

if (search(user, pwd, NULL)) return 0;

else add(user, pwd, coin);

return 1;

}

zhuce()/注册/

{

struct bank p;

int i=0,k=0,judge1,judge2;

char name[30];

char sex,ch;

char sh[18];

int n;

p=(struct bank)malloc(sizeof(struct bank));/给p分配内存/

welcome2();

printf("请输入您的名字(纯英文):");

gets(name);

printf("请输入您的性别(男:1 女2):");

fflush(stdin);

scanf("%c",&sex);

fflush(stdin);

printf("请输入您的身份z号码:");

gets(sh);

for(n=0;n<strlen(name);n++)/判断输入信息是否正确/

{

if(name[n]>='0'&&name[n]<='9')

{

printf("您输入的名字有误!\n");

printf("\n请选择:按1返回主页面 按任意键退出:");

fflush(stdin);

scanf("%c",&ch);

fflush(stdin);

if(ch=='1'){system("cls");main();}

else exit(0);

}

}

if(sex!='1'&&sex!='2')/判断输入信息是否正确/

{

printf("您输入的性别不对!\n");

printf("\n请选择:按1返回主页面 按任意键退出:");

fflush(stdin);

scanf("%c",&ch);

fflush(stdin);

if(ch=='1'){system("cls");main();}

else exit(0);

}

if(strlen(sh)!=18)/判断输入信息是否正确/

{

printf("您输入的身份z号码不全!\n");

printf("\n请选择:按1返回主页面 按任意键退出:");

fflush(stdin);

scanf("%c",&ch);

fflush(stdin);

if(ch=='1'){system("cls");main();}

else exit(0);

}

for(n=0;n<strlen(sh)-1;n++)/判断输入信息是否正确/

{

if(sh[n]<48||sh[n]>57)

{

printf("您输入的身份z号码非法!\n");

printf("\n请选择:按1返回主页面 按任意键退出:");

fflush(stdin);

scanf("%c",&ch);

fflush(stdin);

if(ch=='1'){system("cls");main();}

else exit(0);

}

else

{

if(sh[18]!='x'&&sh[18]<48&&sh[18]>57)

{

printf("您输入的身份z号码非法!\n");

printf("\n请选择:按1返回主页面 按任意键退出:");

fflush(stdin);

scanf("%c",&ch);

fflush(stdin);

if(ch=='1'){system("cls");main();}

else exit(0);

}

}

}

printf("请输入您的帐号(10位纯数字):\n");

fflush(stdin);

scanf("%s",p->id);

fflush(stdin);

while(i <strlen(p->id))

{

if((p->id[i] < 48) || (p->id[i] > 57))

{

judge1=0;

}

i++;

}

while(strlen(p->id)!=10 ||judge1==0)/判断帐号的正确性/

{

printf("您输入的帐号不正确,必须为10位纯数字!");

printf("请重新输入(10位纯数字):");

fflush(stdin);

scanf("%s",p->id);

fflush(stdin);

}

printf("请输入您的密码(6位纯数字):\n");

fflush(stdin);

scanf("%s",p->psw);

fflush(stdin);

while(k <strlen(p->psw))

{

if((p->psw[k] < 48) || (p->psw[k] > 57))

{

judge2=0;

}

k++;

}

while(strlen(p->psw)!=6 ||judge2==0)/判断密码形式的正确性/

{

printf("您输入不正确!密码必须为6位纯数字!\n");

printf("请重新输入密码(6位纯数字):");

fflush(stdin);

scanf("%s",p->psw);

fflush(stdin);

}

printf("请输入您的首期存款:");

fflush(stdin);

scanf("%lf",&p->money);

fflush(stdin);

while((p->money)<100)

{

printf("您必须存入100元以上,请重新输入:");

fflush(stdin);

scanf("%lf",&p->money);

fflush(stdin);

}

if (wenjian(p->id,p->psw,p->money))/存入文件并输出基本信息/

{

system("cls");

printf("注册成功!");

printf("您的注册信息如下,请牢记:\n");

printf("名字:");

puts(name);

printf("性别代码:%c\n",sex);

printf("身份z号码:");

puts(sh);

printf("帐号:");

puts(p->id);

printf("密码:");

puts(p->psw);

printf("您帐户里的余额为:%2lf\n",p->money);

printf("请选择:按1返回主页面 按任意键退出:");

fflush(stdin);

scanf("%c",&ch);

fflush(stdin);

if(ch=='1'){system("cls");main();}

else exit(0);

}

else/如有相同帐号,注册失败/

{

system("cls");

printf("您输入的帐号已经存在!注册失败!\n");

printf("请选择:按1返回主页面 按任意键退出:");

scanf("%c",&ch);

if(ch=='1'){system("cls");main();}

else exit(0);

}

}

gongneng(char Account[10+1],char Password[6+1],double Money)/登陆成功后的功能界面/

{

FILE ps;

struct bank xin[1000];

int k=0,b=0;

char mima[6+1],Chiose,x;

char count[10+1],word[6+1];

double inmoney,outmoney,addmoney;

welcome3();

fflush(stdin);

scanf("%c",&Chiose);

fflush(stdin);

ps=fopen(cFile,"r");

if (!ps)

{

printf("不能打开文件!按任意键退出!");

fflush(stdin);

scanf("%c",&x);

fflush(stdin);

exit(0);

}

if(Chiose=='1')

{

printf("输入您的取款金额:");

fflush(stdin);

scanf("%lf",&outmoney);

fflush(stdin);

while(!feof(ps))

{

fscanf(ps, "%s %s %lf",&xin[k]id,&xin[k]psw,&xin[k]money);

k++;

}

fclose(ps);

ps=fopen(cFile,"wb");

if (!ps)

{

printf("不能打开文件!按任意键退出!");

fflush(stdin);

scanf("%c",&x);

fflush(stdin);

exit(0);

}

while(!feof(ps))

{

//printf("%s %s %2lf\n",xin[b]id,xin[b]psw,xin[b]money);

if ((strcmp(Account, xin[b]id)==0)&&(strcmp(Password, xin[b]psw)==0))

{

xin[b]money=xin[b]money-outmoney;

}

printf("%2lf\n",xin[b]money);

fprintf(ps, "%s %s %2lf\n", xin[b]id, xin[b]psw, xin[b]money);

b++;

}

}

}

denglu()/登陆/

{

FILE fp;

char account[10+ 1],password[6 + 1],h;

int m=0;

char real_account[10+ 1]; / 帐号缓存 /

char real_password[6 + 1]; / 密码缓存/

double real_money_o=00; /存款缓存/

printf("请输入您的帐号(10位纯数字):");

gets(account);

printf("请输入您的密码(6位纯数字):");

gets(password);

fp = fopen(cFile, "r");

if (!fp)

{

printf("不能打开文件!按任意键退出!");

fflush(stdin);

scanf("%c",&h);

fflush(stdin);

exit(0);

}

while (m<=2) /判断是否输入错3次了/

{

while(fscanf(fp, "%s %s %lf", &real_account, &real_password,&real_money_o) != EOF) /循环判断帐号密码/

{

if ((strcmp(real_account, account)==0)&&(strcmp(real_password, password)==0))

{

system("cls");

printf("登陆成功!");

gongneng(real_account,real_password,real_money_o);

fclose(fp);

return 0;

}

}

rewind(fp); /重新打开文件,进行新一轮的密码验证/

printf("您输入的帐号不存在或密码不正确!\n请重新输入:\n");

m++;

printf("请输入您的帐号(10位纯数字):");

fflush(stdin);

gets(account);

fflush(stdin);

printf("请输入您的密码(6位纯数字):");

fflush(stdin);

gets(password);

fflush(stdin);

}

fclose(fp);

printf("您输入帐号密码不正确已经3次,您被强制退出系统(按任意键退出)!");

fflush(stdin);

scanf("%c",&h);

fflush(stdin);

exit(0);

}

int main()

{

char chiose;

welcome1();

scanf("%c",&chiose);

getchar();

if(chiose <='0' ||chiose>='4')

{

while(chiose <='0' || chiose>='4')

{

printf("您的输入有误,请重新输入:");

scanf("%c",&chiose);

getchar();

}

}

if(chiose=='1')

{

system("cls");

zhuce();/注册/

}

if(chiose=='2')

{

system("cls");

denglu();/登陆/

}

if(chiose=='3')

{

printf("谢谢您的使用!");

exit(0);

}

}

打字不易,如满意,望采纳。

使用 C 语言编写一个银行帐户管理系统?你的这个编程要求实在是太高了,肯定是不会有人满足你的要求的。

因为这个要求已经不是简单地答疑 C 语言的语法错误之类的问题了,而是需要从头设计整个该帐户管理系统的各种数据存储结构、以及各种算法(在编写此软件的过程中,肯定需要涉及:到底采用哪一种排序算法效率最高、以及采取哪一种查找算法对人员进行查询效率最高),并且要想彻底从编写一个源程序,到编译、链接、直到该应用软件能够运行出用户所要求的最终正确结果,那是需要花费很多的时间和精力去调试的,而不是只要写出程序代码,即使程序的编程思路是正确的,也不一定能够保证程序的运行结果是正确的。

#include <stdioh>

void main(){

double sum,pri;

int y;

printf("请输入存款数目:");

scanf("%lf",&sum);

pri=sum;

printf("请输入存款年限:");

scanf("%d",&y);

switch (y)

{

case 1:

sum=sum(1+366/100);

break;

case 2:

sum=sum(1+450/100);

break;

case 3:

sum=sum(1+528/100);

break;

case 5:

sum=sum(1+58/100);

break;

default:

sum=sum(1+292/100);

break;

}

printf("%d年过后你的资金总额为:%lf 利息为:%lf\n",y,sum-pri);

}

显示:

请输入存款数目:10000

请输入存款年限:5

5年过后你的资金总额为:10580000000 利息为:580000000

以上就是关于用C语言编银行叫号系统全部的内容,包括:用C语言编银行叫号系统、c语言 设计一个银行管理系统、用C语言设计一个银行账户管理程序 ,账户的信息有账户(唯一)姓名、余额、身份z号码、地址等等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/9996893.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-04
下一篇2023-05-04

发表评论

登录后才能评论

评论列表(0条)

    保存