parent
2d88d3c9fe
commit
f08599eaf1
@ -0,0 +1,9 @@
|
||||
typedef struct bankaccount//定义账户格式模块函数
|
||||
{
|
||||
int account;
|
||||
int key;
|
||||
char name[32];
|
||||
float balance;
|
||||
}BANKACCOUNT;
|
||||
BANKACCOUNT accountcollection[MAXACCOUNT];
|
||||
int cur_account = 0;
|
@ -0,0 +1,14 @@
|
||||
void del_account(FILE *fp,int accountnum)//删除账号信息模块
|
||||
{
|
||||
int i;
|
||||
if(search_account(fp,accountnum)==0)
|
||||
printf("无法找到此账户!\n");
|
||||
else
|
||||
{
|
||||
for(i = 0;i<cur_account-1;i++)
|
||||
if(accountcollection[i].account != accountnum)
|
||||
fprintf(fp,"%d %d %s %.2f\n",
|
||||
accountcollection[i].account,accountcollection[i].key,accountcollection[i].name,accountcollection[i].balance);
|
||||
printf("删除成功!\n");
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
#include<stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct custom
|
||||
{
|
||||
char name[20];
|
||||
char ID[20];
|
||||
char card_number[20];
|
||||
float sum;
|
||||
}a;
|
||||
FILE *fp;
|
||||
char c='Y';
|
||||
fp=fopen("sum.dat","w");//创建只写文件
|
||||
while(c=='Y'||c=='y')//判断循环
|
||||
{
|
||||
printf("输入姓名:");
|
||||
scanf("%s",a.name);
|
||||
getchar();
|
||||
printf("输入身份证号:");
|
||||
scanf("%s",a.ID);
|
||||
printf("输入卡号:");
|
||||
scanf("%s",a.card_number);
|
||||
printf("输入余额:");
|
||||
scanf("%f",&a.sum);
|
||||
fprintf(fp,"%s%s%s%.2f\n",a.name,a.ID,a.card_number,a.sum);
|
||||
while(1)
|
||||
{
|
||||
printf("继续录入?<Y/N>");
|
||||
c=getche();
|
||||
if(c=='Y'||c=='y'||c=='N'||c=='n')
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
void insert_account(FILE *fp)//新建账户模块函数
|
||||
{
|
||||
BANKACCOUNT newaccount;
|
||||
|
||||
printf("请输入账号信息\n");
|
||||
printf(">>账号:");
|
||||
scanf("%d",&(newaccount.account));
|
||||
printf(">>密码:");
|
||||
scanf("%d",&(newaccount.key));
|
||||
printf(">>姓名:");
|
||||
scanf("%s",newaccount.name);
|
||||
printf(">>余额:");
|
||||
scanf("%f",&(newaccount.balance));
|
||||
fseek(fp,0L,SEEK_END);
|
||||
fprintf(fp,"%d %d %s %.2f\n",newaccount.account,newaccount.key,newaccount.name,newaccount.balance);
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
void list_account(FILE *fp)//列出所有账号信息模块函数
|
||||
{
|
||||
int i =0;
|
||||
printf("合计%d个账号:\n",cur_account-1);// cur_account减去多加的1
|
||||
for(i = 0;i< cur_account-1;i++)
|
||||
{
|
||||
printf("账户:%d:\n",i+1);
|
||||
printf("账号:%d\n",accountcollection[i].account);
|
||||
printf("姓名:%s\n",accountcollection[i].name);
|
||||
printf("余额:%.2f\n",accountcollection[i].balance);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
int search_account(FILE *fp,int accountnum)//管理员调用模块函数
|
||||
{
|
||||
int i =0;
|
||||
for(i = 0;i< cur_account-1;i++)
|
||||
{
|
||||
if(accountcollection[i].account == accountnum)
|
||||
{
|
||||
printf("账户:%d:\n",i+1);
|
||||
printf("账号:%d\n",accountcollection[i].account);
|
||||
printf("姓名:%s\n",accountcollection[i].name);
|
||||
printf("余额:%.2f\n",accountcollection[i].balance);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue