(急)!C语言程序设计题---银行帐户管理系统 跪求:C++银行账户管理程序 主要内容: 问题描述 设计一个...

作者&投稿:佴索 (若有异议请与网页底部的电邮联系)
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>

#define BUFFERSIZE 1024
#define MAXACCOUNT 1000
typedef struct BankAccount
{
int account;
int key;
char name[32];
float balance;
}BANKACCOUNT;

BANKACCOUNT accountCollection[MAXACCOUNT];
int curAccount = 0;

void InsertAccount(FILE *fp)
{
BANKACCOUNT newaccount;
printf("please input the account information\n");
printf(">>account num:");
scanf("%d",&(newaccount.account));
printf(">>key:");
scanf("%d",&(newaccount.key));
printf(">>name:");
scanf("%s",newaccount.name);
printf(">>balance:");
scanf("%f",&(newaccount.balance));
fseek(fp,0L,SEEK_END);
fprintf(fp,"%d %d %s %.2f\n",newaccount.account,newaccount.key,newaccount.name,newaccount.balance);
}
void GetAccount(FILE *fp)
{
int accountnum;
int key;
char name[32];
float balance;
int i =0,j;
char buffer[BUFFERSIZE];
int len;
curAccount = 0;
fseek(fp,0,SEEK_SET);
while(!feof(fp)) /* 因为feof()最后会读2遍,所以最后curAccount多加了1 */
{
fscanf(fp,"%d %d %s %f",&accountnum,&key,name,&balance);
accountCollection[curAccount].account = accountnum;
accountCollection[curAccount].key = key;
strcpy(accountCollection[curAccount].name ,name);
accountCollection[curAccount].balance = balance;
curAccount++;
}
}
void ListAccount(FILE *fp)
{
int i =0;
printf("There is %d accounts at all:\n",curAccount-1);/* curAccount减去多加的1 */
for(i = 0;i< curAccount-1;i++)
{
printf("ACCOUNT[%d]:\n",i+1);
printf("account:%d\n",accountCollection[i].account);
printf("name:%s\n",accountCollection[i].name);
printf("balance:%.2f\n",accountCollection[i].balance);
}
}
int SearchAccount(FILE *fp,int accountnum)
{
int i =0;
for(i = 0;i< curAccount-1;i++)
{
if(accountCollection[i].account == accountnum)
{
printf("ACCOUNT[%d]:\n",i+1);
printf("account:%d\n",accountCollection[i].account);
printf("name:%s\n",accountCollection[i].name);
printf("balance:%.2f\n",accountCollection[i].balance);
return 1;
}
}
return 0;
}
void DelAccount(FILE *fp,int accountnum)
{
int i;
if(SearchAccount(fp,accountnum)==0)
printf("Can't find the account\n");
else
{
for(i = 0;i<curAccount-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("delete successfully!\n");
}
}

int main()
{
FILE *fp;
int accountnum;
int i;
do{
system("cls"); //清屏
puts("********************************************");
puts("* You can choose : *");
puts("* 1 : Insert a new Account *");
puts("* 2 : List all Accounts *");
puts("* 3 : Find a Account *");
puts("* 4 : Delete a Account *");
puts("* 5 : quit *");
puts("********************************************");
printf("Please input your choice:");
scanf("%d",&i);
system("cls"); //清屏
switch(i)
{
case 1:
if(!(fp = fopen("account.txt","a+")))
{
printf("can't open the file account.txt\n");
exit(0);
}
InsertAccount( fp);

printf("press any key to continue.....\n");
getch();
fclose(fp);
break;
case 2:
if(!(fp = fopen("account.txt","r")))
{
printf("can't open the file account.txt\n");
exit(0);
}
GetAccount(fp);
ListAccount(fp);

fclose(fp);
printf("press any key to continue.....\n");
getch();
break;
case 3:
printf("please input the account num:\n");
scanf("%d",&accountnum);
if(!(fp = fopen("account.txt","r")))
{
printf("can't open the file account.txt\n");
exit(0);
}
GetAccount(fp);
if(!SearchAccount(fp,accountnum))
printf("There is not the account:%d\n",accountnum);

fclose(fp);
printf("press any key to continue.....\n");
getch();
break;
case 4:
printf("please input the account num:\n");
scanf("%d",&accountnum);
if(!(fp = fopen("account.txt","r")))
{
printf("can't open the file account.txt\n");
exit(0);
}
GetAccount(fp);
fclose(fp);
if(!(fp = fopen("account.txt","w+")))
{
printf("can't open the file account.txt\n");
exit(0);
}
DelAccount(fp,accountnum);
fclose(fp);
printf("press any key to continue.....\n");
getch();
break;
default:
break;
}
}while(i != 5);
return 0;
}

这里账户数据文件名已经设定为account.txt,这个文件要和上面这个程序放在同一个文件夹下面,不然就得用绝对路径(比如"d:\\book\\account.txt"),account内容可以用记事本打开自己改动,然后运行程序后就可以在程序中添加或删除。account.txt一个参考内容如下:
1 10023 zhangsl 100.50
2 32001 sunq 5000.00
3 20010 wangxi 2500.00 4

已将程序发至邮箱

最讨厌的是叫别人代写一大段代码了,我只想说,这东西,求人求天,不如求自己。除非拿rmb,否则很少会有人会为了那么几个金币去写的。

银行存取款管理系统[C语言编写]~

我也想问 可以帮帮忙吗

问题不太清晰。

(急)!C语言程序设计题---银行帐户管理系统
答:include<stdio.h> include<stdlib.h> include<string.h> include<conio.h> define BUFFERSIZE 1024 define MAXACCOUNT 1000 typedef struct BankAccount { int account;int key;char name[32];float balance;}BANKACCOUNT;BANKACCOUNT accountCollection[MAXACCOUNT];int curAccount = 0;void InsertAccoun...

求高人解决一道C语言课程设计题
答:要求:1、用C语言实现系统;2、利用结构体数组实现信息的数据结构设计;3、系统的各个功能模块要求用函数的形式实现;4、界面友好(良好的人机交互),程序加必要的注释。课程设计实验报告要求:1、预习报告:题目、课程设计任务、数据结构、程序的总体设计(算法)、模块划分 。2、实验总结报告:流程图、主要源程序代码(需打印...

求简单的C语言编程,银行账户管理系统
答:简单的管理系统代码(按照你的要求:输入输出加查找)优化如下:include<stdio.h>#include<string.h>struct bank{ char name[20]; char num[20]; double money;};int input(struct bank gusts[],int n);void output(struct bank gusts[],int n);void find(struct bank gusts[],int n);int ...

C语言程序设计题目(急)
答:这段程序中,f 函数使用了一个循环来计算函数值,而 Rf 函数使用了递归。 main 函数提示用户输入 x 和 n 的值,并调用 f 和 Rf 函数计算函数值,最后将结果输出到屏幕上。

c语言程序设计题 急越快越好谢谢!!
答:float sum;for (i = a; i <= b; i++)sum = sum + i;return sum;

C语言程序设计题求解,急…
答:一、include<stdio.h> int main(){ float x,y;float h,c,j,s;printf("输入两个实型数:");scanf("%f%f",&x,&y);h= x+y;c= x-y;j = x*y;s = x/y;printf("x,y的和,差,积和商分别为%f,%f,%f,%f\n",h,c,j,s);return 0;} 二、include<stdio.h> int main(){...

C语言程序设计题目 急急急
答:A) 2 B) 4 C) 1 D) 3 13.设int i=2, j=1, k=3,则表达式i&&(i+j)&k|i+j的值为(C )A) 0 B) 2 C) 1 D) 3 14.执行下面的程序段后,变量 y的值是( B )int x=35,y;char z=’A’;y=(x&5)&&(z<’a’);A) 0 B) 1 C) 2 ...

C语言程序设计题 求解 急!!!
答:22、int a[10]; 不要漏了后面的分号, 语句是以分号结尾的。23、此题有问题,如果数组是局部的,那么其成员的值是随机的,如果是全局数组,其成员的值是0;24、*(*(a+i)+j)25、10 26、n > 9 && n < 100 27、x*y*y/(3*a)+4*b-1 28、2020 29、printf("%c ", 'Z'-i)...

c语言程序设计教程答案c语言程序设计练习题
答:篇一:c语言程序设计基础单元总结与练习题及答案 《C语言程序设计》单元总结与练习题 答案 单元一 程序设计宏观认识 单元总结提升 本单元中,核心内容有C语言程序框架结构、程序的构成和程序开发过程。通过本单元 的学习,我们应该知道: 1.C语言程序最基本的程序框架由两部分构成,分别是: (1) 编译预处理 (2) 函数...

《C语言程序设计》练习题
答:一、选择题 1、C语言规定,在一个源程序中,main()函数的位置(C )。A) 必须在最开始 B)必须在最后 C) 可以任意 D) 必须在系统调用的库函数后面 这题你死记就行,你看看这个 任何一个C++程序都必须定义一个main函数,它的返回类型总是int类型。这个函数由操作系统来调用,在main函 数...