steam怎样steam添加不了好友好友

2089人阅读
C语言的学习(题)(12)
Created by lanqs on 14/12/17.
Copyright (c) 2014年
All rights reserved.
#include &stdio.h&
#include &haha.h&
struct Zhanghu{
char name[20];//姓名
struct Zhanghu A = {&小王&,,10000};//A
struct Zhanghu B = {&小李&,,20000};//B
struct Zhanghu C = {&银行&,,100000};//C 银行账户ATM机子(里面有钱。。。银行的钱。。。)
int main(int argc, const char * argv[]) {
#pragma mark -
用C语言控制台程序模拟一个ATM 机存取款流程。
1) 账户基本信息结构体(包括:姓名、账户、密码、余额等基本信息)。
2) 输入用户名密码登录(密码用户名自定义并且提示相关错误信息)。
3) 登录成功后有:查看余额、取款、存款、修改密码 、退出登录菜单,并实现相关功能。
4)新建两个用户A(初始资金1W)、B(初始资金2W),并添加一个银行账户(总资金10W,A、B用户资金计入在内)处理资金平衡,并记录相关操作日志。
注:1)排版及代码规范;
2)需要添加注释
3)功能完整性
4)增强用户体验
int flag = 0;//a,b登陆成功的标示
int flag1 = 0;
// 进入打印凭条的标示
qukuan = 0; //额,这个就是存取款变量
//----------------因为是取款机,所以程序是死循环
//------------功能实现
//------------输入账号密码登陆(密码修改后使用新密码登陆)
//------------查看余额(每次操作后会更新)
//------------取款(不能取超过机子的钱,也不能透支)
//------------存款(随便存)
//------------修改密码,同上
//------------退出登陆(退出了这个操作机子的人,等待下一个继续操作这台ATM机子)
//------------输入内部的银行账户可以登陆查看A,B的信息,还有ATM机子的余额情况
//------------初始密码都在上面。。。
//------------ -_-||要停止运行请拆电池。。。
while (1) {
printf(&程序一直运行中。。。\n&);
printf(&请输入账号和密码:&);
scanf(&%d%d&,&num,&password);
if (num == A.num && password == A.password) {
int kongzhi = 1; //a,b中的控制
printf(&a登陆成功!&);
while (kongzhi) {
printf(&\n1.查看余额\n&);
printf(&2.取款\n&);
printf(&3.存款\n&);
printf(&4.修改密码\n&);
printf(&5.退出登录\n&);
scanf(&%d&,&a);//输入选择信息
switch (a) {
//1.查看余额
printf(&余额为:%.2lf&,A.balance);
printf(&\n-----------------------\n&);
printf(&请输入你要取款的金额:&);
scanf(&%lf&,&qukuan);
//取款这里不能为0啊
if (qukuan &= A.balance) {
A.balance = A.balance -
C.balance = C.balance - //取款机的余额减少
printf(&取款成功!&);
}else if (qukuan & C.balance){
printf(&取款机余额不足!&);
printf(&余额不足!&);
printf(&\n-----------------------\n&);
printf(&请输入你要存款的金额:&);
scanf(&%lf&,&qukuan);
A.balance = A.balance +
C.balance = C.balance + //取款机里面的前增加
printf(&\n存款成功!\n&);
printf(&\n-----------------------\n&);
printf(&请输入新的密码:&);
scanf(&%d&,&password);
A.password =
printf(&\n密码修改成功!\n&);
printf(&\n-----------------------\n&);
printf(&你已经退出了!&);
printf(&\n-----------------------\n&);
kongzhi = 0;
printf(&输入错误!&);
printf(&\n-----------------------\n&);
}else if (num == B.num && password == B.password){
int kongzhi = 1; //a,b中的控制
while (kongzhi) {
printf(&b登陆成功&);
printf(&\n1.查看余额\n&);
printf(&2.取款\n&);
printf(&3.存款\n&);
printf(&4.修改密码\n&);
printf(&5.退出登录\n&);
scanf(&%d&,&a);//输入选择信息
switch (a) {
//1.查看余额
printf(&余额为:%.2lf&,B.balance);
printf(&\n-----------------------\n&);
printf(&请输入你要取款的金额:&);
scanf(&%lf&,&qukuan);
if (qukuan &= B.balance) {
B.balance = B.balance -
C.balance = C.balance -//取款机里面的钱减少
printf(&取款成功!&);
}else if (qukuan & C.balance){
printf(&取款机余额不足!&);
printf(&余额不足!&);
printf(&\n-----------------------\n&);
printf(&请输入你要存款的金额:&);
scanf(&%lf&,&qukuan);
B.balance = B.balance +
C.balance = C.balance + //取款机里面的前增加
printf(&\n存款成功!\n&);
printf(&\n-----------------------\n&);
printf(&请输入新的密码:&);
scanf(&%d&,&password);
B.password =
printf(&\n密码修改成功!\n&);
printf(&\n-----------------------\n&);
printf(&你已经退出了!&);
printf(&\n-----------------------\n&);
kongzhi = 0 ;
printf(&输入错误!&);
printf(&\n-----------------------\n&);
}else if(num == C.num && password == C.password){
printf(&银行账户登陆成功!\n&);
printf(&ATM机的余额%.2lf\n&,C.balance);
printf(&户主:%s,账号%d, 余额:%.2lf\n&,B.name,B.num,B.balance);
printf(&户主:%s,账号%d, 余额:%.2lf\n&,A.name,A.num,A.balance);
printf(&你的账号或者密码输入有错!请重新输入:\n&);
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:110117次
积分:2543
积分:2543
排名:第13728名
原创:138篇
转载:88篇
评论:28条
(1)(2)(12)(30)(67)(114)C语言实现ATM机存取款系统 - C语言 - 编程入门网
C语言实现ATM机存取款系统
利用结构体和构造函数并且采用输入输出文件实现ATM机系统。
主要功能有:
利用三种方法查询、开户、登陆、菜单、取款、修改密码、存款、转账、创建个人信息、输出、删除、增加、退出。
是一个功能齐全,完备的ATM机系统。
#include&stdio.h&
#include&string.h&
#include&stdlib.h&
struct per
//定义结构体
char name[20];
char ID[20];
char mima[6];
struct per *
typedef struct person
//定义另一结构体
struct person *
void chaxun(struct per *head);
//各个函数的声明
void kaihu(struct per *head);
void denglu(struct per *head);
void caidan(struct per *head);
void qukuan(struct per *head);
void xgmm(struct per *head);
void cunkuan(struct per *head);
void zhuanzhang(struct per *head);
void chuangjian(struct person **Phead);
void shuchu(struct person *Phead);
void shanchu(struct person **Phead);
void zengjia(struct person **Phead);
void chaxun1(struct person *Phead);
void chaxun2(struct person *Phead);
void chaxun3(struct person *Phead);
void tuichu();
void menu();
/*主函数*/
//////////////////////////////////////////////////
void main()
//choose为定义输入选择的变量
int flag=1;
struct person *Phead=NULL; //Phead为定义二层头指针
struct per *head=NULL;
//head为定义一层头指针
printf(&*****************************\n&);
printf(&**欢迎使用ATM自动取款机系统**\n&);
printf(&*****************************\n&);
printf(&&&&&&&&&&&&&&&\n&);
printf(&&&&&&&&&&&&&&&\n&);
printf(&&&&&&&&&&&&&&&\n&);
前台客户信息查询中心|\n&);
printf(&&&&&&&&&&&&&&&\n&);
请选择您的需求
printf(&&&&&&&&&&&&&&&\n&);
scanf(&%s&,&x);
system(&cls&);
case '1':system(&cls&);
kaihu(head);
//调用开户函数
case '2':system(&cls&);
denglu(head);
//调用登陆函数
case '3':system(&cls&);
//调用后台菜单函数
while(flag)
system(&cls&);
//调用后台菜单函数
choose=getchar();
switch(choose)
case '1':chuangjian(&Phead);
shuchu(Phead); //调用后台输出函数
system(&pause&);
system(&cls&);
case '2':chaxun1(Phead); //调用后台卡号查询函数
system(&pause&);
system(&cls&);
case '3':chaxun2(Phead); //调用后台姓名查询函数
system(&pause&);
system(&cls&);
chaxun3(Phead); //调用后台余额查询函数
system(&pause&);
system(&cls&);
case '5':shanchu(&Phead); //调用后台删除用户函数
system(&pause&);
system(&cls&);
zengjia(&Phead); //调用后台增加用户函数
system(&pause&);
system(&cls&);
case '7':shuchu(Phead); //调用后台输出函数函数
system(&pause&);
system(&cls&);
case '8':shuchu(Phead);
system(&pause&);
system(&cls&);
case '0':flag=0;
printf(&The end.\n&);
/*开户函数*/
////////////////////////////////////////////////////////
void kaihu(struct per *head)
head=NULL;
//定义文件指针
struct per *p1=NULL,*p2=NULL;
//p1,p2为定义链表指针
p1=(struct per*)malloc(sizeof(struct per));
//开辟内存单元
printf(&请输入您的姓名:\n&);
//请数据输入链表中
scanf(&%s&,p1-&name);
printf(&请设置您的卡号:\n&);
scanf(&%s&,p1-&ID);
printf(&请设置您银行卡密码:\n&);
scanf(&%s&,p1-&mima);
p1-&money=0;
p1-&next=NULL;
printf(&您的个人信息为&);
printf(&姓名:%s \n卡号:%s \n余额:%4d\n&,p1-&name,p1-&ID,p1-&money);
if(NULL==head)
//为新用户开辟内存单元
head=(struct per *)malloc(sizeof(struct per));
head-&next=p1;
//进行头插法,将其作为第一个节点
//为新增客户开辟内存单元
for(p2=p2-&next!=NULL;p2=p2-&next); //进行尾插
p2-&next=p1;
if((fp=fopen(&save.txt&,&ab+&))==NULL) //打开文件
printf(&cannot poen file\n&);
if(fwrite(p1,sizeof(struct per),1,fp)!=1)
//将链表信息写入文件中
printf(&file write error\n&);
fclose(fp);
printf(&\n&);
printf(&恭喜您开户成功,请登录\n&);
system(&pause&);
system(&cls&);
denglu(head);
//登陆函数
/////////////////////////////////////////////////////
void denglu(struct per *head)
char d[20];
char mima[20];
//定义文件指针
struct per *p,*q=NULL;
if((fp=fopen(&save.txt&,&rb+&))==NULL)
//打开一个二进制文件,为读方式
printf(&不能打开文件\n&);
//如不能打开,则结束程序
p=(struct per*)malloc(sizeof(struct per));
//申请空间
while(!feof(fp))
//循环读数据直到文件尾结束
if(1!=fread(p,sizeof(struct per),1,fp))
//如果没读到数据,跳出循环
p-&next=(struct per *)malloc(sizeof(struct per));
//为下一个结点申请空间
//保存当前节点的指针,作为下一结点的前驱
//指针后移,新读入数据链到当前表尾
q-&next=NULL;
//最后一个结点的后继指针为空
fclose(fp);
**********************\n&);
***欢迎来都建设银行***\n&);
**********************\n&);
for(j=1;j&4;j++)
//限制卡号输入的次数的循环
printf(&请输入您的卡号\n&);
scanf(&%s&,d);
for(q=q!=NULL;q=q-&next)
//遍历链表
if(strcmp(q-&ID,d)!=0)
//核对账号
//跳出循环
for(i=1;i&4;i++)
//限制密码输入的次数的循环
printf(&\n\n请输入您的密码\n&);
scanf(&%s&,mima);
if(strcmp(q-&mima,mima)!=0)
//核对密码
printf(&密码不正确。请重新输入密码\n&);
system(&pause&);
system(&cls&);
//若密码不对,跳出循环
system(&cls&);
caidan(head);
//调用菜单函数
printf(&\n\n\n您输入密码三次错误,谢谢光临\n&);
system(&pause&);
system(&cls&);
printf(&\n\n\n您输入的卡号有误,请重试\n&);
system(&pause&);
system(&cls&);
printf(&您的卡号三次输入错误,谢谢使用\n&);
//银行菜单函数
/////////////////////////////////////////////////////////////
void caidan(struct per *head)
head=NULL;
//i为客户选择输入的变量
printf(&请选择您需要的业务\n&);
//银行业务菜单
printf(&*********************************\n&);
printf(&**
printf(&*********************************\n&);
printf(&**
4 修改密码**\n&);
printf(&*********************************\n&);
printf(&**
printf(&*********************************\n&);
scanf(&%d&,&i);
if(i&6||i&0)
case 1:qukuan(head);
//调用银行取款函数
system(&pause&);
system(&cls&);
case 2:system(&cls&);
chaxun(head);
//调用银行查询函数
case 3:system(&cls&);
zhuanzhang(head);
//调用银行转账函数
case 4:system(&cls&);
xgmm(head);
//调用银行修改密码函数
case 5:system(&cls&);
cunkuan(head);
//调用银行存款函数
case 6:system(&cls&);
//调用银行退出函数
printf(&您的输入有误\n&);
system(&pause&);
system(&cls&);
//银行取款函数
//////////////////////////////////////////////////
void qukuan(struct per *head)
head=NULL;
//head为链表头指针
//定义文件指针
struct per *p,*q=NULL;
if((fp=fopen(&save.txt&,&rb+&))==NULL) //打开一个二进制文件,为读方式
printf(&不能打开文件\n&);
//如不能打开,则结束程序
p=(struct per*)malloc(sizeof(struct per));
//申请空间
while(!feof(fp))
//循环读数据直到文件尾结束
if(1!=fread(p,sizeof(struct per),1,fp))
//如果没有读到数据,跳出循环
p-&next=(struct per *)malloc(sizeof(struct per));
//为下一个结点申请空间
//保存当前结点的指针,作为下一个结点的前驱
//指针后移,新读入数据链到当前表尾
q-&next=NULL;
//最后一个结点的后继指针为空
fclose(fp);
system(&cls&);
printf(&************************************\n&);
printf(&**
printf(&************************************\n&);
printf(&**
printf(&************************************\n&);
printf(&**
printf(&************************************\n&);
printf(&请按要求选择您要取款的金额\n&);
scanf(&%d&,&i);
if(i&6||i&=0)
//限制输入范围
printf(&对不起,您的输入有误\n\n&);
//对应选项乘以一百为取款金额
if(i&q-&money)
printf(&对不起,您的金额不足\n&);
system(&pause&);
system(&cls&);
caidan(head);
//调用取款机菜单函数
q-&money-=i;
//对金额进行处理
if((fp=fopen(&save.txt&,&wb+&))==NULL)
//打开文件
printf(&cannot open file\n&);
if(fwrite(q,sizeof(struct per),1,fp)!=1) //将修改的信息重新写入文件
printf(&file write error\n&);
printf(&您已经成功取走%d元\n&);
q-&next=NULL;
fclose(fp);
//关闭文件
//银行转账函数
/////////////////////////////////////////////
void zhuanzhang(struct per *head)
head=NULL;
//定义文件指针
struct per *p,*q=NULL;
if((fp=fopen(&save.txt&,&rb+&))==NULL)
//打开一个二进制文件,为读方式
printf(&不能打开文件\n&);
//如不能打开,则结束程序
p=(struct per*)malloc(sizeof(struct per));
//申请空间
while(!feof(fp))
//循环读数据直到文件尾结束
if(1!=fread(p,sizeof(struct per),1,fp))
//如果没读到数据,跳出循环
p-&next=(struct per *)malloc(sizeof(struct per));
//为下一个结点申请空间
//保存当前结点的指针,作为下一个结点的前驱
//指针后移,新读入数据链到当前表尾
q-&next=NULL;
//最后一个结点的后继指针为空
fclose(fp);
int i,j,k;
printf(&请输入帐号号码\n&);
scanf(&%d&,&i);
printf(&请再次输入帐号号码\n&);
//核对卡号
scanf(&%d&,&j);
printf(&两次账号不同,请重新输入\n&);
zhuanzhang(head);
system(&cls&);
printf(&************************************\n&);
printf(&**
printf(&************************************\n&);
printf(&**
printf(&************************************\n&);
printf(&**
printf(&************************************\n&);
printf(&请输入转账金额\n&);
scanf(&%d&,&k);
if(k&6||k&=0)
printf(&对不起,您的输入有误\n\n&);
if(k&q-&money)
//对余额进行判断
printf(&对不起,您的余额不足\n&);
system(&pause&);
system(&cls&);
caidan(head);
printf(&您已成功转账%d元\n&,k);
q-&money-=k;
if((fp=fopen(&save.txt&,&wb+&))==NULL)
printf(&cannot open file\n&);
if(fwrite(q,sizeof(per),1,fp)!=1)
//将数据重新写入文件
printf(&file write error\n&);
q-&next=NULL;
fclose(fp);
system(&pause&);
system(&cls&);
//银行查询函数
/////////////////////////////////////////////////
void chaxun(struct per *head)
head=NULL;
//链表头指针
//定义文件指针
struct per *p,*q=NULL;
if((fp=fopen(&save.txt&,&rb+&))==NULL)
//打开一个二进制文件,为读方式
printf(&不能打开文件\n&);
//如不能打开,则结束程序
p=(struct per*)malloc(sizeof(struct per));
//申请空间
while(!feof(fp))
//循环读数据直到文件尾结束
if(1!=fread(p,sizeof(struct per),1,fp))
//如果没读到数据,跳出循环
p-&next=(struct per *)malloc(sizeof(struct per));
//为下一个结点申请空间
//保存当前结点的指针,作为下一个结点的前驱
//指针后移,新读入数据链到当前表尾
q-&next=NULL;
//最后一个结点的后继指针为空
fclose(fp);
printf(&您卡上原有余额%d元\n\n&,q-&money);
system(&pause&);
system(&cls&);
//银行修改密码函数
//////////////////////////////////////////////////
void xgmm(struct per *head)
head=NULL;
//链表头指针
char mima[20];
//定义文件指针
struct per *p,*q=NULL;
if((fp=fopen(&save.txt&,&rb+&))==NULL)
//打开一个二进制文件,为读方式
printf(&不能打开文件\n&);
//如不能打开,则结束程序
p=(struct per*)malloc(sizeof(struct per));
//申请空间
while(!feof(fp))
//循环读数据直到文件尾结束
if(1!=fread(p,sizeof(struct per),1,fp))
//如果没读到数据,跳出循环
p-&next=(struct per *)malloc(sizeof(struct per));
//为下一个结点申请空间
//保存当前结点的指针,作为下一个结点的前驱
//指针后移,新读入数据链到当前表尾
q-&next=NULL;
//最后一个结点的后继指针为空
fclose(fp);
printf(&请输入您的原密码\n&);
scanf(&%s&,mima);
if(strcmp(q-&mima,mima)==0)
//核对密码
printf(&密码正确\n&);
printf(&请输入您的新密码:\n&);
scanf(&%s&,q-&mima);
if((fp=fopen(&save.txt&,&wb+&))==NULL)
//文件头指针
printf(&cannot open file\n&);
if(fwrite(q,sizeof(struct per),1,fp)!=1)
//将修改的密码重新写入文件
printf(&file write error\n&);
fclose(fp);
printf(&修改密码成功\n\n\n\n\n&);
printf(&您输入的密码与原密码不同\n&);
system(&pause&);
q-&next=NULL;
//银行存款函数
////////////////////////////////////
void cunkuan(struct per *head)
head=NULL;
//链表头指针
//定义文件指针
struct per *p,*q=NULL;
if((fp=fopen(&save.txt&,&rb+&))==NULL)
//打开一个二进制文件,为读方式
printf(&不能打开文件\n&);
//如不能打开,则结束程序
p=(struct per*)malloc(sizeof(struct per));
//申请空间
while(!feof(fp))
//循环读数据直到文件尾结束
if(1!=fread(p,sizeof(struct per),1,fp))
//如果没读到数据,跳出循环
p-&next=(struct per *)malloc(sizeof(struct per));
//为下一个结点申请空间
//保存当前结点的指针,作为下一个结点的前驱
//指针后移,新读入数据链到当前表尾
q-&next=NULL;
//最后一个结点的后继指针为空
fclose(fp);
system(&cls&);
printf(&您卡上原有余额%d元\n&,q-&money);
printf(&************************************\n&);
printf(&**
printf(&************************************\n&);
printf(&**
printf(&************************************\n&);
printf(&**
printf(&************************************\n&);
printf(&请选择您要存入的余额\n&);
scanf(&%d&,&i);
if(i&6||i&=0)
printf(&对不起,您的输入有误\n\n&);
q-&money+=i;
if((fp=fopen(&save.txt&,&wb+&))==NULL)
//打开文件
printf(&cannot open file\n&);
if(fwrite(q,sizeof(struct per),1,fp)!=1)
//将修改的密码重新写入文件
printf(&file write error\n&);
printf(&您已经成功存取%d元\n&,i);
q-&next=NULL;
fclose(fp);
system(&pause&);
system(&cls&);
//退出银行函数
///////////////////////////////////////////
void tuichu()
printf(&谢谢使用\n&);
//后台运行菜单函数
///////////////////////////////////////////////////////
void menu()
printf(&****************欢迎来到建设银行取款机系统****************\n\n\n\n&);
printf(&**************************************************\n&);
printf(&**** 1 建立信息并显示
2 卡号查询信息 ****\n&);
printf(&**************************************************\n&);
printf(&**** 3 姓名查询信息
4 余额查询信息 ****\n&);
printf(&**************************************************\n&);
printf(&**** 5 删除某卡号信息
6 增加新的用户 ****\n&);
printf(&**************************************************\n&);
printf(&**** 7 按余额降序输出
printf(&**************************************************\n&);
printf(&**** 0 退出
printf(&**************************************************\n&);
printf(&请选择您需要的业务\n\n&);
//后台运行创建链表函数
////////////////////////////////////////////////////
void chuangjian(struct person **Phead)
//*(*Phead)为指向结构体指针的地址
struct person *p,*t;
//定义操作指针
char n[20];
char a[20];
if(*Phead) *Phead=NULL;
printf(&请输入卡号 姓名 余额 (若要结束请输入三个为零)\n&);
printf(&请输入卡号\n&);
scanf(&%s&,n);
printf(&请输入姓名\n&);
scanf(&%s&,a);
printf(&请输入预存金额\n&);
scanf(&%d&,&s);
p=(L *)malloc(sizeof(L));
//将信息输入链表中
strcpy(p-&kehu.ID,n);
strcpy(p-&kehu.name,a);
//将指针重新指向头指针
printf(&请输入卡号\n&);
scanf(&%s&,n);
printf(&请输入姓名\n&);
scanf(&%s&,a);
printf(&请输入预存金额\n&);
scanf(&%d&,&s);
//将p的值赋给t,p又可以储存下一个结点
p=(L *)malloc(sizeof(L));
//为新结点开辟新的内存
strcpy(p-&kehu.ID,n);
strcpy(p-&kehu.name,a);
p-&kehu.money=s;
p-&next=NULL;
t-&next=p;
//将p的值接在t(即上一个结点的后面)
printf(&请输入卡号\n&);
scanf(&%s&,n);
printf(&请输入姓名\n&);
scanf(&%s&,a);
printf(&请输入预存金额\n&);
scanf(&%d&,&s);
//后台运行输出链表函数
/////////////////////////////////////////////
void shuchu(struct person *Phead)
printf(&\n\n&);
if(NULL==Phead)
printf(&没有客户信息可输出!\n&);
//若头指针指向空,则没有客户信息
while(Phead)
//遍历输出链表中所有客户信息
printf(&卡号:%s\n姓名:\n余额:%d\n&,Phead-&kehu.ID,Phead-&kehu.name,Phead-&kehu.money);
Phead=Phead-&
printf(&\n\n&);
//后台运行卡号查询函数
///////////////////////////////////////////////////
void chaxun1(struct person*Phead)
char m[20];
//定义输入查找客户卡号的变量
if(NULL==Phead)
//若头指针向空,则没有客户信息
printf(&没有客户信息可查询!\n&);
printf(&请输入要查询的客户卡号:\n&);
scanf(&%s&,m);
while(NULL!=Phead&&strcmp(Phead-&kehu.ID,m)!=0)
//在链表中遍历寻找中,直到链表存在并且卡号核对无误
Phead=Phead-&
if(Phead==NULL)
//若指针指最后指向空,则没有客户信息
printf(&对不起,没有该用户!\n&);
printf(&卡号:%s\n姓名:\n余额:%d\n&,Phead-&kehu.ID,Phead-&kehu.name,Phead-&kehu.money);
//若找到,则输出客户信息
//后台运行姓名查询函数
/////////////////////////////////////////////////////
void chaxun2(struct person *Phead)
char m[20];
//定义输入查找客户卡号的变量
if(NULL==Phead)
//若头指针向空,则没有客户信息
printf(&没有客户信息可查询!\n&);
printf(&请输入要查询的客户姓名:\n&);
scanf(&%s&,m);
while(NULL!=Phead&&strcmp(Phead-&kehu.name,m)!=0)
//在链表中遍历寻找中,直到链表存在并且姓名核对无误
Phead=Phead-&
if(Phead==NULL)
//若指针指最后指向空,则没有客户信息
printf(&对不起,没有该用户!\n&);
printf(&卡号:%s\n姓名:\n余额:%d\n&,Phead-&kehu.ID,Phead-&kehu.name,Phead-&kehu.money);
//若找到,则输出客户信息
//后台运行余额查询函数
/////////////////////////////////////////////////////
void chaxun3(struct person *Phead)
//定义输入查找客户余额的变量
if(NULL==Phead)
//若头指针向空,则没有客户信息
printf(&没有客户信息可查询!\n&);
printf(&请输入要查询的客户信息的余额:\n&);
scanf(&%ld&,&x);
while(NULL!=Phead&&Phead-&kehu.money!=x)
//在链表中遍历寻找中,直到链表存在并且余额核对无误,继续寻找
Phead=Phead-&
if(Phead==NULL)
//若指针指最后指向空,则没有客户信息
printf(&对不起,没有该用户!\n&);
printf(&该客户的信息为\n&);
printf(&卡号:%s\n姓名:\n余额:%d\n&,Phead-&kehu.ID,Phead-&kehu.name,Phead-&kehu.money);
//若找到,则输出客户信息
//后台运行删除客户信息函数
///////////////////////////////////////////////////
void shanchu(struct person **Phead)
//*(*Phead)为指向结构体指针的地址
char k[20];
//定义输入查找客户姓名卡号的变量
struct person *p=*Phead,*t;
if(NULL==(*Phead))
//若指针最后指向空,则没有客户信息
printf(&没有客户信息可删除!\n&);
printf(&请输入要删除的客户卡号:\n&);
scanf(&%s&,k);
if(p-&kehu.ID==k)
//若第一个客户就是,则让头指针指向下一个结点
*Phead=(*Phead)-&next,free(p);
while(NULL==p-&next&&p-&next-&kehu.ID!=k)
//遍历寻找,核对客户卡号
//当p-&next没指向空,并且客户的卡号还没找到,则继续寻找
if(p-&next==NULL)
printf(&对不起,没有该客户!\n&);
//如果找到,则把p-&next的值赋给t
p-&next=p-&next-&
//后台运行增加用户信息函数
////////////////////////////////////////////////////////////
void zengjia(struct person **Phead)
//*(*Phead) 为指向结构体指针的地址
char n[20];
//定义输入增加客户卡号的变量
char a[20];
//定义输入增加客户姓名的变量
L *p,*t,*k;
//定义操作指针变量
printf(&请输入要插入的客户信息\n&);
printf(&请输入卡号\n&);
scanf(&%s&,&n);
printf(&请输入姓名\n&);
scanf(&%s&,a);
printf(&请输入预存金额\n&);
scanf(&%d&,&s);
p=(L *)malloc(sizeof(L));
//开辟空间
strcpy(p-&kehu.ID,a);
//将新的客户信息写入链表
p-&kehu.money=s;
strcpy(p-&kehu.name,n);
if(NULL==(*Phead))
//如果是空链表,则把新客户信息作为第一个结点
(*Phead)-&next=NULL;
p-&next=(*Phead);
(*Phead)=p;
下一篇:没有了

我要回帖

更多关于 steam咋加好友 的文章

 

随机推荐