master
m59637281 6 years ago
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,47 +0,0 @@
#include<stdio.h>
#include<string.h>
int main(void)
{
int n;
char words[100][100][100];
char word[100];
char password[100];
while (scanf("%d", &n) != EOF)
{
getchar();
if (n == 1)
{
int i = 0;
gets(word);
gets(password)
while (words[i][0][0] != '\0')
{
if (strcmp(words[i][0], word) == 0 && strcmp(words[i][1], password) == 0)
{
scanf("%d", &n);
getchar();
switch(n)
{
case 1:
break;
case 2:
break;
case 3:
break;
default:
printf("您输入的数字不正确请输入1,2,3中的任意一个数\n");
break;
}
}
i++;
}
}
else if(n == 0)
{
}
else
printf("您输入的数字不正确请输入0,1中的其中一个数\n");
}
return 0;
}

@ -0,0 +1,22 @@
void get_account(FILE *fp)//搜索账号信息模块函数
{
int accountnum;
int key;
char name[32];
float balance;
int i =0,j;
char buffer[BUFFERSIZE];
int len;
cur_account = 0;
fseek(fp,0,SEEK_SET);
while(!feof(fp)) // 因为feof()最后会读2遍所以最后curAccount多加了1
{
fscanf(fp,"%d %d %s %f",&accountnum,&key,name,&balance);
accountcollection[cur_account].account = accountnum;
accountcollection[cur_account].key = key;
strcpy(accountcollection[cur_account].name ,name);
accountcollection[cur_account].balance = balance;
cur_account++;
}
}

@ -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…
Cancel
Save