本篇文章给大家谈谈c语言个人账目管理系统,以及c语言个人记账系统对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
1、求大神们帮帮忙,帮我用c语言编写一个银行账户管理系统!要不回不了家了。。2、编写一个C语言程序模拟银行ATM机的账户管理功能,系统主要实现以下功能3、求助C语言编译个人财务管理系统!(尽快啊)4、用C语言编一个程序,建立一个简单的银行帐户管理系统5、(急)!C语言程序设计题—银行帐户管理系统
求大神们帮帮忙,帮我用c语言编写一个银行账户管理系统!要不回不了家了。。
#includestdio.h
#includestring.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 main()
{
struct bank gusts[100];
int n,choose;
printf(“请输入要录入数据条数:”);
scanf(“%d”,n);
input(gusts,n);
printf(“按照提示选择相应的操作!\n”);
while(1)
{
printf(“1:查找 2输出 0结束\n”);
scanf(“%d”,choose);
if(choose==0)
break;
switch(choose){
case 1:find(gusts,n);break;
case 2:output(gusts,n);break;
default:printf(“无此操作!\n”);break;
}
}
return 0;
}
int input(struct bank gusts[],int n)
{
int i;
if(n100)
{
printf(“数据过多!\n”);
return 0;
}
printf(“按以下格式输入%d条数据!\n”,n);//加了一条提示
printf(“姓名 账号 金额 \n”);
for(i=0;in;i++)
{
scanf(“%s %s %lf”,gusts[i].name,gusts[i].num,gusts[i].money);//账号不要带空格
}
printf(“成功录入%d条账户数据!\n”,n);
return 0;
}
void output(struct bank gusts[],int n)
{
int i;
printf(“姓名 账号 金额 \n”);
for(i=0;in;i++)
{
printf(“%d:%s %s %0.3lf\n”,i+1,gusts[i].name,gusts[i].num,gusts[i].money);
}
printf(“成功输出所有账户数据!\n”);
}
void find(struct bank gusts[],int n)
{
int i,choose;
int count;
char name[20],num[20];
printf(“请输入查找类型对应的数字编号[1-3]:1姓名查找 2账户查找 3编号查找 4结束查找:\n”);
while(1){
scanf(“%d”,choose);
if(choose==4)
break;
else if(choose1||choose3)
{
printf(“无此种查找!请重新选择!\n”);
continue;
}
count=0;
switch(choose){
case 1:
printf(“请输入查找的客户姓名:”);
scanf(“%s”,name);
printf(“查询结果如下:\n姓名 账户 编号\n”);
for(i=0;in;i++)
{
if(strcmp(gusts[i].name,name)==0)
{
printf(“%d:%s %s %0.3lf\n”,i+1,gusts[i].name,gusts[i].num,gusts[i].money);
count++;
}
}
printf(“共查询到%d条结果!\n”,count);//加入结果统计
break;
case 2:
printf(“请输入查找的客户账户:”);
scanf(“%s”,num);
printf(“查询结果如下:\n姓名 账户 编号\n”);
for(i=0;in;i++)
{
if(strcmp(gusts[i].num,num)==0)
{
count++;
printf(“%d:%s %s %0.3lf\n”,i+1,gusts[i].name,gusts[i].num,gusts[i].money);
}
}
printf(“共查询到%d条结果!\n”,count);//加入结果统计
break;
case 3:
printf(“请输入查找的客户编号:”);
scanf(“%d”,i);
printf(“查询结果如下:\n姓名 账户 编号\n”);
printf(“%d:%s %s %0.3lf\n”,i+1,gusts[i].name,gusts[i].num,gusts[i].money);
break;
}
}
}
编写一个C语言程序模拟银行ATM机的账户管理功能,系统主要实现以下功能
按照你的愿意把空都填好了,VC++ 6.0下编译能通过,有警告信息,运行基本上能用,不过个人认为这个系统有很大的不足,比如输入账号的时候没有输出反馈信息,以及没有对误操作的处理等等。需要的话可以帮你改改!
#include stdio.h
#include conio.h
#include stdlib.h
#include string.h
#define AN 9 //表示账号8位
#define PN 7 //表示密码6位
#define ASN 3 //表示系统中共有3个账户信息
struct Account
{
char accountnumber[AN]; //表示账号信息
char password[PN]; //表示账户的密码信息
double balance; //表示账户的余额
};
struct Account ats[ASN]={{“00000001″,”123456”,100},{“00000002″,”123456”,200},{“00000003″,”123456”,300}};
//ats数组用于存储系统中三个账户的信息
int isCorrect(char *an,char *psd)
{
int i;
for(i=0;iASN;i++)
if(strcmp(ats[i].accountnumber,an)==0 strcmp(psd,ats[i].password)==0)
return 1;
return 0;
}
double getBalance(char *an)
{
int i;
for(i=0;iASN;i++)
if(strcmp(an,ats[i].accountnumber)==0)
return ats[i].balance;
}
void deposit(char *an,int amount)
{
int i;
for(i=0;iASN;i++)
if(strcmp(an,ats[i].accountnumber)==0)
ats[i].balance+=amount;
}
int withdraw(char *an,int amount)
{
int i;
for(i=0;iASN;i++)
if(strcmp(an,ats[i].accountnumber)==0)
return ats[i].balance-=amount;
}
void main()
{
char AccountNumber[AN]={‘\0’};
char psd[PN]={‘\0’};
int i,errorcount=0;
while(1)
{
printf(“\n请输入8位账号:”);
for(i=0;i8;i++)
AccountNumber[i]=getch();
printf(“\n请输入6为密码:”);
for(i=0;i6;i++)
{
psd[i]=getch();
putchar(‘*’);
}
if(isCorrect(AccountNumber,psd)==1)
{
int tag,amount;
while(1)
{
printf(“\n欢迎登录银行账户管理系统,请选择您要的服务:1、查询余额;2、存款操作;3、取款操作;4、退出系统\n”);
scanf(“%d”,tag);
switch(tag)
{
case 1:
printf(“您现在的余额为%f元\n”,getBalance(AccountNumber));
break;
case 2:
printf(“请输入您的存款金额:”);
scanf(“%d”,amount);
deposit(AccountNumber,amount);
printf(“存款成功!您的当前余额为:%f元\n”,getBalance(AccountNumber));
break;
case 3:
printf(“请输入您的取款金额:”);
scanf(“%d”,amount);
if(amount=getBalance(AccountNumber))
printf(“取款成功!您的当前余额为:%f元\n”,withdraw(AccountNumber,amount));
else
printf(“取款失败!\n”);
break;
case 4:
break;
}
if(tag==4)
break;
}
}
else
{
errorcount++;
if(errorcount==3)
{
printf(“您已经连续三次输入错误,系统将自动关闭\n”);
break;
}
}
}
}
求助C语言编译个人财务管理系统!(尽快啊)
/******头文件(.h)***********/
#include “stdio.h” /*I/O函数*/
#include “stdlib.h” /*标准库函数*/
#include “string.h”/*字符串函数*/
#include “ctype.h” /*字符操作函数*/
#define M 200 /*定义常数表示记录数*/
typedef struct /*定义数据结构*/
{
char name[20]; /*姓名*/
char units[30]; /*单位*/
char tele[10]; /*电话*/
char product_company[30];/* 生产厂家 */
char designer[30]; /* 设计者 */
char price[10]; /* 价格 */
char kucun[10]; /* 库存量 */
char year[4]; /* 出厂年份 */
char month[2]; /* 出厂月份 */
char day[2]; /* 出厂 */
}ADDRESS;
/******以下是函数原型*******/
int enter(ADDRESS t[]); /*输入记录*/
void list(ADDRESS t[],int n); /*显示记录*/
void search(ADDRESS t[],int n); /*按姓名查找显示记录*/
int delete(ADDRESS t[],int n); /*删除记录*/
int add(ADDRESS t[],int n); /*插入记录*/
void save(ADDRESS t[],int n); /*记录保存为文件*/
int load(ADDRESS t[]); /*从文件中读记录*/
void display(ADDRESS t[]); /*按序号查找显示记录*/
void sort(ADDRESS t[],int n); /*按姓名排序*/
void modify_price(ADDRESS t[],int n); /*快速查找记录*/
void copy(); /*文件复制*/
void print(ADDRESS temp); /*显示单条记录*/
int find(ADDRESS t[],int n,char *s) ; /*查找函数*/
int menu_select(); /*主菜单函数*/
/******主函数开始*******/
main()
{
int i;
ADDRESS adr[M]; /*定义结构体数组*/
int length=0; /*保存记录长度*/
clrscr(); /*清屏*/
for(;;)/*无限循环*/
{
clrscr(); /*清屏*/
switch(menu_select()) /*调用主菜单函数,返回值整数作开关语句的条件*/
{
case 0:length=enter(adr);break;/*输入记录*/
case 1:list(adr,length);break; /*显示全部记录*/
case 2:search(adr,length);break; /*查找记录*/
case 3:length=delete(adr,length);break; /*删除记录*/
case 4:length=add(adr,length); break; /*插入记录*/
case 5:save(adr,length);break; /*保存文件*/
case 6:modify_kucun(adr,length); break; /*读文件*/
case 7:display(adr);break; /*按序号显示记录*/
case 8:sort(adr,length);break; /*按姓名排序*/
case 9:modify_kucun(adr,length);break; /*快速查找记录*/
case 10:copy();break; /*复制文件*/
case 11:exit(0); /*如返回值为11则程序结束*/
}
}
}
/*菜单函数,函数返回值为整数,代表所选的菜单项*/
menu_select()
{
char s[80];
int c;
/*gotoxy(1,25);*//* 将光标定为在第25行,第1列*/
printf(“press any key enter menu……\n”);/*提示压任意键继续*/
getch(); /*读入任意字符*/
clrscr(); /*清屏*/
/*gotoxy(1,1); */
printf(“********************MENU*********************\n\n”);
printf(” 0. Enter record\n”);
printf(” 1. List the file\n”);
printf(” 2. Search record on name\n”);
printf(” 3. Delete a record\n”);
printf(” 4. add record \n”);
printf(” 5. Save the file\n”);
printf(” 6. Modify kucun\n”);
printf(” 7. Display record on order\n”);
printf(” 8. Sort to make new file\n”);
printf(” 9. Quick seek record\n”);
printf(” 10. Copy the file to new file\n”);
printf(” 11. Quit\n”);
printf(“***********************************************\n”);
do{
printf(“\n Enter you choice(0~11):”); /*提示输入选项*/
scanf(“%s”,s); /*输入选择项*/
c=atoi(s); /*将输入的字符串转化为整型数*/
}while(c0||c11); /*选择项不在0~11之间重输*/
clrscr(); /*清屏*/
return c; /*返回选择项,主程序根据该数调用相应的函数*/
}
/***输入记录,形参为结构体数组,函数值返回类型为整型表示记录长度*/
int enter(ADDRESS t[])
{
int i,n;
char *s;
clrscr(); /*清屏*/
do{
printf(“\nHow many numbers do you want to record?\nplease input the numbers you wanted:\n”); /*提示信息*/
scanf(“%d”,n); /*输入记录数*/
if(n==0)
printf(“the num couldn’t be ‘0’!Please enter again!”);
}while(n==0);
printf(“please input record! \n”); /*提示输入记录*/
printf(“name|unit|telephone|product_company|designer|price|kucun|year|month|day\n”);
printf(“————————————————\n”);
for(i=0;in;i++)
{
/*scanf(“%s %s %s %s %s %s %s %s %s %s”,t[i].name,t[i].units,t[i].tele,t[i].product_company,t[i].designer,t[i].price,t[i].kucun,t[i].year,t[i].month,t[i].day); *//*输入记录*/
printf(“name:”); /* 打印输出号码 */
scanf(“%s”,t[i].name);/* 用数组输入号码 */
printf(“unit:”); /* 打印输出名字 */
scanf(“%s”,t[i].units); /* 用数组输入姓名 */
printf(“telephone:”);/* 打印输出性别 */
scanf(“%s”,t[i].tele);/* 用数组输入性别 */
printf(“product_company:”); /* 打印输出生日 */
scanf(“%s”,t[i].product_company); /* 用数组输入生日 */
printf(“designer:”);/* 打印输出婚姻状况 */
scanf(“%s”,t[i].designer);/* 用数组输入婚姻状况 */
printf(“price:”);/* 打印输出工作状况 */
scanf(“%s”,t[i].price);/* 用数组输入工作状况 */
printf(“kucun:”);/* 打印输出工作状况 */
scanf(“%s”,t[i].kucun);/* 用数组输入工作状况 */
printf(“produce year:”);/* 打印输出工作状况 */
scanf(“%s”,t[i].year);/* 用数组输入工作状况 */
printf(“produce month:”);/* 打印输出工作状况 */
scanf(“%s”,t[i].month);/* 用数组输入工作状况 */
printf(“produce day:”);/* 打印输出工作状况 */
scanf(“%s”,t[i].day);/* 用数组输入工作状况 */
printf(“———–Ok!this record have been recorded!————\n”);
}
printf(“the all have been recorded!\n”);
getch();
clrscr();
return n; /*返回记录条数*/
}
/*显示记录,参数为记录数组和记录条数*/
void list(ADDRESS t[],int n)
{
int i;
clrscr();
printf(“\n\n*******************ADDRESS******************\n”);
printf(“name|unit|telephone|product_company|designer|price|kucun|year|month|day\n”);
printf(“————————————————————————\n”);
if(n!=0)
for(i=0;in;i++)
{
printf(“%s/%s/%s/%s/%s/%s/%s/%s/%s/%s”,t[i].name,t[i].units,t[i].tele,t[i].product_company,t[i].designer,t[i].price,t[i].kucun,t[i].year,t[i].month,t[i].day);
if((i+1)%10==0) /*判断输出是否达到10条记录*/
{
printf(“Press any key continue…\n”); /*提示信息*/
getch(); /*压任意键继续*/
}
}
else printf(“there is no record!\n”);
printf(“************************end*******************\n”);
}
/*查找记录*/
void search(ADDRESS t[],int n)
{
char s[20]; /*保存待查找姓名字符串*/
int i; /*保存查找到结点的序号*/
/*clrscr(); */
printf(“please input the search name:\n”);
scanf(“%s”,s); /*输入待查找姓名*/
i=find(t,n,s); /*调用find函数,得到一个整数*/
if(in-1) /*如果整数i值大于n-1,说明没找到*/
printf(“not found!\n”);
else
print(t[i]); /*找到,调用显示函数显示记录*/
clrscr();
}
/*显示指定的一条记录*/
void print(ADDRESS temp)
{
/* clrscr(); */
printf(“\n\n********************************************\n”);
printf(“name|unit|telephone|product_company|designer|price|kucun|year|month|day\n”);
/*printf(“————————————————\n”); */
printf(“%s/%s/%s/%s/%s/%s/%s/%s/%s/%s”,temp.name,temp.units,temp.tele,temp.product_company,temp.designer,temp.price,temp.kucun,temp.year,temp.month,temp.day);
printf(“**********************end***********************\n”);
}
/*查找函数,参数为记录数组和记录条数以及姓名s */
int find(ADDRESS t[],int n,char *s)
{
int i;
for(i=0;in;i++)/*从第一条记录开始,直到最后一条*/
{
if(strcmp(s,t[i].name)==0) /*记录中的姓名和待比较的姓名是否相等*/
return i; /*相等,则返回该记录的下标号,程序提前结结束*/
}
return i; /*返回i值*/
}
/*删除函数,参数为记录数组和记录条数*/
int delete(ADDRESS t[],int n)
{
char s[20]; /*要删除记录的姓名*/
int ch=0;
int i,j;
printf(“please deleted name\n”); /*提示信息*/
scanf(“%s”,s);/*输入姓名*/
i=find(t,n,s); /*调用find函数*/
if(in-1) /*如果in-1超过了数组的长度*/
printf(“no found not deleted\n”); /*显示没找到要删除的记录*/
else
{
print(t[i]); /*调用输出函数显示该条记录信息*/
printf(“Are you sure delete it(1/0)\n”); /*确认是否要删除*/
scanf(“%d”,ch); /*输入一个整数0或1*/
if(ch==1) /*如果确认删除整数为1*/
{
for(j=i+1;jn;j++) /*删除该记录,实际后续记录前移*/
{
strcpy(t[j-1].name,t[j].name); /*将后一条记录的姓名拷贝到前一条*/
strcpy(t[j-1].units,t[j].units); /*将后一条记录的单位拷贝到前一条*/
strcpy(t[j-1].tele,t[j].tele); /*将后一条记录的电话拷贝到前一条*/
strcpy(t[j-1].product_company,t[j].product_company);
strcpy(t[j-1].designer,t[j].designer);
strcpy(t[j-1].price,t[j].price);
strcpy(t[j-1].kucun,t[j].kucun);
strcpy(t[j-1].year,t[j].year);
strcpy(t[j-1].month,t[j].month);
strcpy(t[j-1].day,t[j].day);
}
n–; /*记录数减1*/
}
}
return n; /*返回记录数*/
}
/*插入记录函数,参数为结构体数组和记录数*/
int add(ADDRESS t[],int n)/*插入函数,参数为结构体数组和记录数*/
{
ADDRESS temp; /*新插入记录信息*/
int i,j;
char s[20],p; /*确定插入在哪个记录之前*/
printf(“please input the new record:\n”);
printf(“************************************************\n”);
printf(“name|unit|telephone|product_company|designer|price|kucun|year|month|day\n”);
/*printf(“————————————————–\n”);
scanf(“%s%s%s”,temp.name,temp.units,temp.tele); *//* 输入插入信息*/
printf(“name:”); /* 打印输出号码 */
scanf(“%s”,temp.name);/* 用数组输入号码 */
printf(“unit:”); /* 打印输出名字 */
scanf(“%s”,temp.units); /* 用数组输入姓名 */
printf(“telephone:”);/* 打印输出性别 */
scanf(“%s”,temp.tele);/* 用数组输入性别 */
printf(“product_company:”); /* 打印输出生日 */
scanf(“%s”,temp.product_company); /* 用数组输入生日 */
printf(“designer:”);/* 打印输出婚姻状况 */
scanf(“%s”,temp.designer);/* 用数组输入婚姻状况 */
printf(“price:”);/* 打印输出工作状况 */
scanf(“%s”,temp.price);/* 用数组输入工作状况 */
printf(“kucun:”);/* 打印输出工作状况 */
scanf(“%s”,temp.kucun);/* 用数组输入工作状况 */
printf(“produce year:”);/* 打印输出工作状况 */
scanf(“%s”,temp.year);/* 用数组输入工作状况 */
printf(“produce month:”);/* 打印输出工作状况 */
scanf(“%s”,temp.month);/* 用数组输入工作状况 */
printf(“produce day:”);/* 打印输出工作状况 */
scanf(“%s”,temp.day);/* 用数组输入工作状况 */
printf(“———–Ok!this record have been recorded!————\n”);
printf(“————————————————\n”);
K:printf(“please input the wanted name’s position to insert:\n”);
scanf(“%s”,s); /*输入插入位置的姓名*/
i=find(t,n,s); /*调用find,确定插入位置*/
if(in-1) /*如果in-1超过了数组的长度*/
{
printf(“the name isn’t exist!\n”); /*显示没找到要删除的记录*/
printf(“Are you want to continue to insert?Yes–y/No–any other key!\n”);
if(getch()==’y’) goto K;
}
else
{
for(j=n-1;j=i;j–) /*从最后一个结点开始向后移动一条*/
{
strcpy(t[j+1].name,t[j].name); /*当前记录的姓名拷贝到后一条*/
strcpy(t[j+1].units,t[j].units); /*当前记录的单位拷贝到后一条*/
strcpy(t[j+1].tele,t[j].tele); /*当前记录的电话拷贝到后一条*/
strcpy(t[j+1].product_company,t[j].product_company);
strcpy(t[j+1].designer,t[j].designer);
strcpy(t[j+1].price,t[j].price);
strcpy(t[j+1].kucun,t[j].kucun);
strcpy(t[j+1].year,t[j].year);
strcpy(t[j+1].month,t[j].month);
strcpy(t[j+1].day,t[j].day);
}
strcpy(t[i].name,temp.name); /*将新插入记录的姓名拷贝到第i个位置*/
strcpy(t[i].units,temp.units); /*将新插入记录的单位拷贝到第i个位置*/
strcpy(t[i].tele,temp.tele); /*将新插入记录的电话拷贝到第i个位置*/
strcpy(t[i].product_company,temp.product_company);
strcpy(t[i].designer,temp.designer);
strcpy(t[i].price,temp.price);
strcpy(t[i].kucun,temp.kucun);
strcpy(t[i].year,temp.year);
strcpy(t[i].month,temp.month);
strcpy(t[i].day,temp.day);
n++; /*记录数加1*/
return n; /*返回记录数*/
}
}
/*保存函数,参数为结构体数组和记录数*/
void save(ADDRESS t[],int n)
{
int i;
FILE *fp; /*指向文件的指针*/
if((fp=fopen(“record.txt”,”wb”))==NULL) /*打开文件,并判断打开是否正常*/
{
printf(“can not open file\n”);/*没打开*/
exit(1); /*退出*/
}
printf(“\nSaving file now!\n”); /*输出提示信息*/
fprintf(fp,”there is %d records!”,n); /*将记录数写入文件*/
fprintf(fp,”\r\n”); /*将换行符号写入文件*/
for(i=0;in;i++)
{
fprintf(fp,”%s/%s/%s/%s/%s/%s/%s/%s/%s/%s”,t[i].name,t[i].units,t[i].tele,t[i].product_company,t[i].designer,t[i].price,t[i].kucun,t[i].year,t[i].month,t[i].day);/*格式写入记录*/
fprintf(fp,”\r\n”); /*将换行符号写入文件*/
}
fclose(fp);/*关闭文件*/
printf(“****save success***\n”); /*显示保存成功*/
}
/*读入函数,参数为结构体数组*/
/* int load(ADDRESS t[]) */
/* { */
/* int i,n; */
/* FILE *fp; *//*指向文件的指针*/
/* if((fp=fopen(“record.txt”,”rb”))==NULL)*//* 打开文件*/
/* { */
/* printf(“can not open file\n”); *//*不能打开*/
/* exit(1); *//*退出*/
/* } */
/* fscanf(fp,”%d”,n);*/ /*读入记录数*/
/* for(i=0;in;i++) */
/* fscanf(fp,”%20s%30s%10s”,t[i].name,t[i].units,t[i].tele); */ /*按格式读入记录*/
/* fclose(fp);*/ /*关闭文件*/
/* printf(“You have success read data from file!!!\n”); *//* 显示保存成功*/
/* return n;*/ /*返回记录数*/
/* } */
/*按序号显示记录函数*/
int modify_kucun(ADDRESS t[],int n)
{
char s[20],ch[10]; /*保存待查找姓名字符串*/
int i,j; /*保存查找到结点的序号*/
/*clrscr(); */
printf(“please input the cloth name which you wanted to modify its kucun:\n”);
scanf(“%s”,s); /*输入待查找姓名*/
i=find(t,n,s); /*调用find函数,得到一个整数*/
if(in-1) /*如果整数i值大于n-1,说明没找到*/
printf(“sorry!the name don’t exist!\n”);
else
{
print(t[i]); /*找到,调用显示函数显示记录*/
/*printf(“Are you sure to modify its kucun?Yes–y/”); */
printf(“please input the new kucun you want:\n”);
scanf(“%c”,ch);
for(j=0;j10;j++)
t[i].kucun[j]=ch[j];
printf(“Ok!the kucun has been modified!”);
}
clrscr();
}
void display(ADDRESS t[])
{
int id,n;
FILE *fp; /*指向文件的指针*/
if((fp=fopen(“record.txt”,”rb”))==NULL) /*打开文件*/
{
printf(“can not open file\n”); /*不能打开文件*/
exit(1); /*退出*/
}
printf(“Enter order number:\n”); /*显示信息*/
scanf(“%d”,id); /*输入序号*/
fscanf(fp,”%d”,n); /*从文件读入记录数*/
if(id=0idn) /*判断序号是否在记录范围内*/
{
fseek(fp,(id-1)*sizeof(ADDRESS),1); /*移动文件指针到该记录位置*/
print(t[id]); /*调用输出函数显示该记录*/
printf(“\r\n”);
}
else
printf(“no %d number record!!!\n “,id); /*如果序号不合理显示信息*/
fclose(fp); /*关闭文件*/
}
/*排序函数,参数为结构体数组和记录数*/
void sort(ADDRESS t[],int n)
{
int i,j,flag;
char y;
ADDRESS temp; /*临时变量做交换数据用*/
R: printf(“Please select which kind to sort!0–sort by kucun/1–sort by Chu_Chang_Ri_Qi\n “); /*选择何种方式排序*/
if(getch()==’0′)
{
for(i=0;in;i++)
{
flag=0; /*设标志判断是否发生过交换*/
for(j=0;jn-1;j++)
if((strcmp(t[j].kucun,t[j+1].kucun))0) /*比较大小*/
{
flag=1;
strcpy(temp.name,t[j].name); /*交换记录*/
strcpy(temp.units,t[j].units);
strcpy(temp.tele,t[j].tele);
strcpy(temp.product_company,t[j].product_company);
strcpy(temp.designer,t[j].designer);
strcpy(temp.price,t[j].price);
strcpy(temp.kucun,t[j].kucun);
strcpy(temp.year,t[j].year);
strcpy(temp.month,t[j].month);
strcpy(temp.day,t[j].day);
strcpy(t[j].name,t[j+1].name);
strcpy(t[j].units,t[j+1].units);
strcpy(t[j].tele,t[j+1].tele);
strcpy(t[j].product_company,t[j+1].product_company);
strcpy(t[j].designer,t[j+1].designer);
strcpy(t[j].price,t[j+1].price);
strcpy(t[j].kucun,t[j+1].kucun);
strcpy(t[j].year,t[j+1].year);
strcpy(t[j].month,t[j+1].month);
strcpy(t[j].day,t[j+1].day);
strcpy(t[j+1].name,temp.name);
strcpy(t[j+1].units,temp.units);
strcpy(t[j+1].tele,temp.tele);
strcpy(t[j+1].product_company,temp.product_company);
strcpy(t[j+1].designer,temp.designer);
strcpy(t[j+1].price,temp.price);
strcpy(t[j+1].kucun,temp.kucun);
strcpy(t[j+1].year,temp.year);
strcpy(t[j+1].month,temp.month);
strcpy(t[j+1].day,temp.day);
}
if(flag==0) break; /*如果标志为0,说明没有发生过交换循环结束*/
}
printf(“sort sucess!!!\n”); /*显示排序成功*/
}
else
if(getch()==’1′)
{
for(i=0;in;i++)
{
flag=0; /*设标志判断是否发生过交换*/
for(j=0;jn-1;j++)
/* if((()((strcmp(t[j].month,t[j+1].month))0)))
((strcmp(t[j].day,t[j+1].day))0))||
(((strcmp(t[j].year,t[j+1].year))=0)((strcmp(t[j].month,t[j+1].month))0))||
(((strcmp(t[j].year,t[j+1].year))=0)((strcmp(t[j].month,t[j+1].month))=0)((strcmp(t[j].day,t[j+1].day))0))) *//*比较大小*/
if(( ((strcmp(t[j].year,t[j+1].year))0)((strcmp(t[j].month,t[j+1].month))0)((strcmp(t[j].day,t[j+1].day))0) )||
( ((strcmp(t[j].year,t[j+1].year))==0)((strcmp(t[j].month,t[j+1].month))0) )||
( ((strcmp(t[j].year,t[j+1].year))==0)((strcmp(t[j].month,t[j+1].month))==0)((strcmp(t[j].day,t[j+1].day))0) ))
{
flag=1;
strcpy(temp.name,t[j].name); /*交换记录*/
用C语言编一个程序,建立一个简单的银行帐户管理系统
#include stdio.h #include string.h struct information { char account[20]; char IDcardNum; char workUint; char homeAddress; float money; char cardNum; long int password; }; void openAccount(); { cardNum++; user[cardNum].cardNum = cardNum; printf(“请输入您的姓名:”); gets(user[cardNum].account); printf(“请输入您的身份证号:”); gets(user[cardNum].IDcardNum); printf(“请输入您的工作单位:”); gets(user[cardNum].workUnit); print(“请输入您的家庭住址:”); gets(user[cardNum].homeAddress); printf(“请输入您的密码:”); gets(user[cardNum].password); printf(“请输入您要存入的金额:”); scanf(“%d”,user[cardNum].money); //写入文件out.txt中,写入后,光标移至下一行 read();//读取文件 write(); //写入文件 cardNum++; } void deposit(); { int money; printf(“请输入您的卡号:”); scanf(“%d”,cardNum); printf(“请输入您要存入的金额:”); scanf(“%f”,money); user[cardNum].money = user[cardNum].money + money; printf(“您现在账户中的余额是¥%f”,user[cardNum].money); } void withdraw(); { int money; printf(“请输入您的卡号:”); scanf(“%d”,cardNum); printf(“请输入您要存入的金额:”); scanf(“%f”,money); user[cardNum].money = user[cardNum].money – money; printf(“您现在账户中的余额是¥%f”,user[cardNum].money); } void changeInformation(); { printf(“请输入您的卡号:”); scanf(“%d”,cardNum); user[cardNum].cardNum = cardNum; printf(“请输入您的姓名:”); gets(user[cardNum].account); printf(“请输入您的身份证号:”); gets(user[cardNum].IDcardNum); printf(“请输入您的工作单位:”); gets(user[cardNum].workUnit); print(“请输入您的家庭住址:”); gets(user[cardNum].homeAddress); printf(“请输入您的密码:”); gets(user[cardNum].password); printf(“请输入您要存入的金额:”); scanf(“%d”,user[cardNum].money); //写入文件out.txt中,写入后,光标移至下一行 read();//读取文件 write(); //写入文件 } void reportLoss(); { } void closeAccount(); { } void read(); { } void write(); { } int main() { int i; unsigned long int cardNum = 00001; information user[cardNum]; printf(“请您选择要进行的操作:\n”); printf(“——————————————————\n”); printf(“1、开户/办卡 2、存款 3、取款 4、修改信息 5、挂失 6、销户\n”); printf(“——————————————————\n”); scanf(“%d”,i); if(i 1 || i 6) printf(“ERROR!\n”); else { switch(i) { case 1 : openAccount(); break; case 2 : deposit(); break; case 3 : withdraw(); break; case 4 : changeInformation(); break; case 5 : reportLoss(); break; case 6 : closeAccount(); break; } } return 0; } 没有写完,楼主可以参考一下!
(急)!C语言程序设计题—银行帐户管理系统
#includestdio.h
#includestdlib.h
#includestring.h
#includeconio.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;icurAccount-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
c语言个人账目管理系统的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于c语言个人记账系统、c语言个人账目管理系统的信息别忘了在本站进行查找喔。