|
![]() | 作者: lwei889 [lwei889]
![]() |
登录 |
#include <graphics.h> #include <open.c> /*保存有开户函数*/ #include <account.c> /*保存已有帐户函数*/ main() /*主程序*/ {struct ATM *openaccount(struct ATM *p[]); /*函数声明*/ void myaccount(void); char choice; /*键盘选择变量*/ clrscr(); do{ /*选择操作界面*/ printf("\n\t\tATM Program!"); printf("\n\t=================================="); printf("\n\t\t1:Open an new account!"); printf("\n\t\t2:Use my account!"); printf("\n\t\t3:Exit!"); printf("\n\t=================================="); printf("\n\tplease input your choice:"); choice=getch(); switch(choice) {case '1':openaccount(q); break; case '2':myaccount(); break; case '3':free(q); /*释放指针所占用的内存*/ printf("\n\n\tIf your trade doesn't over,please don't leave off!"); printf("\n\n\t**Thanks for your use! See you again!**"); printf("\n\n\t **Press any key to EXIT!**"); getch(); break; default:printf("\n\tYour choice error!"); } }while(choice!='3'); } 以下是open.c的内容 #include <stdio.h> #include <stdlib.h> #include <string.h> #define LEN sizeof(struct ATM) typedef struct ATM link; static int flag=0; /*全局变量,用来控制输入次数和作实参传递*/ struct ATM /*此结构体,用来记录用户信息*/ { char name[10]; /*ueser name*/ long password; /*ueser passwork*/ char ID[16]; /*ueser ID card*/ int year,month,day; long money; unsigned long account; }*q[10],user; struct ATM *openaccount(struct ATM *p[]) /*开户函数*/ { int i; clrscr(); randomize(); printf("\n\n\n\t\t***Welcome Use ATM****"); for(i=flag;i<=flag;i++) {q[i]=(struct ATM *)malloc(LEN); /*动态分配一段内存*/ if(i!=0) getchar(); printf("\n\n\n\tplease input you name:"); /*输入用户名*/ scanf("%s",p[i]->name); printf("\n\tplease input your password:"); /*输入密码*/ printf("\n\t **Wanging:password onlg form of six data,don't include string!"); /*提示密码只能为6位且不能有字符*/ printf("\n\tinput your password:"); scanf("%ld",&p[i]->password); printf("\n\tplease input your ID card:"); /*输入用户身份证*/ scanf("%s",p[i]->ID); printf("\n\tplease input year month and day:"); /*输入开户日期*/ scanf("%d%d%d",&p[i]->year,&p[i]->month,&p[i]->day); printf("\n\tinput your account money:"); /*输入开户金额*/ scanf("%ld",&p[i]->money); printf("\n\tOk,Success!Please rember your account:"); /*随机产生一个帐号*/ p[i]->account=random(1000000000000)+10000000000000000; printf("%ld",p[i]->account); printf("\n\tDo you continue?(y/n)"); /*以下语句段是用来控制是不是继续开户*/ { char ch; ch=getch(); if(ch=='y'||ch=='Y') /*从键盘上得到一个字符,如果是y或Y则继续,否则退出*/ flag++; else { clrscr(); flag++; break; } } } return; } 以下是account.c的内容 #include <saving.c> void myaccount(void) /*已经存在的函数*/ {void saving(int n); /*存取款函数声明*/ int i,count=0; /*初始化count用来作标志*/ clrscr(); printf("\n\t\t\t***Welcome Use ATM***"); printf("\n\n\tPlease input your account:"); /*输入已经存在的帐号*/ scanf("%ld",&user.account); printf("\n\tPlease input your password:"); /*输入匹配的密码*/ scanf("%ld",&user.password); for(i=0;i<flag;i++) /*flag为静态全局变量,所以可以使用*/ { if((user.account==q[i]->account)&&(user.password==q[i]->password)) /*检查帐号和密码是否匹配*/ { count++; /*count为标志变量,用来标识是否执行if语句*/ saving(i); /*调用存取款函数*/ } } if(count==0) /*如果count=0,则说明没有执行if,提示出错信息*/ printf("\n\tPlease input checked your accont or password!"); } 以下是saving.c的内容 void saving(int n) {char choice; /*变量声明,用作键盘选择*/ long money,password,account,password1; /*辅助变量定义*/ int i; clrscr(); do{printf("\n\n\t\t\tWelcome use ATM!"); /*输出用户选择界面*/ printf("\n\t**************************************************"); printf("\n\t\t1:Save Money!"); printf("\t\t2:Get Money!"); printf("\n\t\t3:Check Money!"); printf("\t\t4:Turn Money!"); printf("\n\t\t5:Modify Password"); printf("\t6:Exit"); printf("\n\t\t **RMB Sorts: 50 100**"); printf("\n\t**************************************************"); printf("\n\tplease input your choice:"); choice=getch(); printf("\n\t\t******************************"); switch(choice) {case '1':printf("\n\tInput your saving money:"); /*存款操作*/ scanf("%ld",&money); if(money%50==0){ /*控制用户输入金额为50的倍数*/ q[n]->money+=money; printf("\n\tOk,Success!"); } else { /*提示出错信息*/ printf("\n\tError!You enter the data isn't the times of 50!"); printf("\n\tplease enter times of 50 ! "); } printf("\n\tPress any key...."); getch(); break; case '2':printf("\n\tInput your get money:"); /*取款操作*/ scanf("%ld",&money); if(money%50==0){ /*控制用户取款金额为50的倍数*/ if(money<=q[n]->money) { q[n]->money-=money; printf("\n\tOk,Success!"); } else { /*给出出错信息*/ printf("\n\tMoney not enough!"); } } else { printf("\n\tError!You enter the data isn't the time of 50!"); printf("\n\tplease enter times of 50 ! "); } printf("\n\tPress any key...."); getch(); break; case '3':printf("\n\tYour money is:%ld",q[n]->money); /*查询余额操作*/ printf("\n\tPress any key...."); getch(); break; case '4':printf("\n\tplease input your money:"); /*转帐操作*/ scanf("%ld",&money); if(money>q[n]->money) /*转帐金额检查*/ printf("\n\tError!Money is not enough!"); else{ printf("\n\tplease input your another account:"); /*输入目标帐号*/ scanf("%ld",&account); printf("\n\tplease input your password:"); /*匹配密码*/ scanf("%ld",&password); for(i=0;i<=flag;i++) /*帐号和密码检查*/ if(account==q[i]->account&&password==q[i]->password&&i!=n) {q[i]->money+=money; /*转帐赋值语句*/ q[n]->money-=money; i=0; printf("\n\tOk,success!"); break; } if(i!=0) /*给出出错信息*/ printf("\n\tFailor,please checked your password or use different accont!"); } printf("\n\tPress any key...."); getch(); break; case '5':printf("\n\tplease input your new password:"); /*修改密码操作*/ scanf("%ld",&password); printf("\n\tplease input your new password again:"); scanf("%ld",&password1); if(password==password1) /*对两次输入进行检查*/ { q[n]->password=password; printf("\n\t0k,please rember!"); } else printf("\n\tError!Two input "); /*如果两次不一致,给出信息*/ printf("\n\tPress any key...."); getch(); break; case '6':printf("\n\t If the machine leads your lossing,please touch with Administrator."); /*退出存取款操作*/ printf("\n\tThanks for your use !"); printf("\n\tplease take your card!"); getch(); break; default:printf("\n\tYour choice error!"); } } while(choice!='6'); /*如果choice=6则退出*/ } 在tc2.0下调试成功,由于我的英语水平问题,所以加的是中文注释,但不影响程序的执行,(有开户,存款,取款,转帐,查询,修改密码功能),但还有很多不完善的地方,所以希望各位看到后,别忘了给我留意见,不管是哪个方面的,我都会虚心接受! 我喜爱编程,所以你的意见和指导,将会给我带来进步 呵呵,看后别忘了回贴哦,一个真心求知的人在等待你的建议和指点!! |
地主 发表时间: 11/24 20:23 |
![]() | 回复: ceo_8008 [ceo_8008] ![]() |
登录 |
好! |
B1层 发表时间: 11/24 20:46 |
![]() | 回复: rshu [rshu] ![]() |
登录 |
不是太懂,不知你调试好运行过没有 |
B2层 发表时间: 11/24 21:51 |
![]() | 回复: bluedomb [bluedomb] ![]() |
登录 |
scanf("%s",p[i]->ID); 是什么意思 不好意思我刚学"->"有什么用??是按顺序输入吗?? |
B3层 发表时间: 11/25 17:15 |
![]() | 回复: jbcsk [jbcsk] ![]() |
登录 |
希望调试好以后不要发布出来!对以后的银行业有很大的破坏!最好是把软件发给公安部做参考!这样以后的网络银行系统会更家稳定! |
B4层 发表时间: 11/25 17:19 |
![]() | 回复: lwei889 [lwei889] ![]() |
登录 |
这个程序已经调试好,能够运行 p[i]->ID 这是一种表示形式,因为p[]是定义的指向结构体的指针数组 另外,想问一下楼上的,为什么调试好因为不要发布,我不知道怎么会对银行业有很大的破坏?是不是这个程序的漏洞有很多,当然我是初学者,你可以给予指点!! |
B5层 发表时间: 11/25 20:24 |
![]() | 回复: jbcsk [jbcsk] ![]() |
登录 |
你考虑一下后果! 如果有些不法的公司那你的程序加以改造!会对现在的中国有什么影响? |
B6层 发表时间: 11/26 11:26 |
![]() | 回复: 286 [unique] ![]() |
登录 |
说什么呢?会有什么影响?呵呵,有意思?! |
B7层 发表时间: 11/26 11:44 |
![]() | 回复: lwei889 [lwei889] ![]() |
登录 |
这只是个模拟程序,至于它和真正的自动取款机程序相差有多远,不用说,应该可以想象的到!! 另外,要是别的公司要是能修改的话,技术肯定比我强的多,我想他又不会这样做拉,我想他们会搞一套破解程序。 (假如说,要真是用到自动取款机里,我想源代码不会公布的) 还是要谢谢魔鬼教练的,能够这样关心中国银行业,真的很难得? (你是不是在银行里工作啊 随便问的,没有别的意思?) |
B8层 发表时间: 11/26 12:49 |
![]() | 回复: a [tbs5201314] ![]() |
登录 |
偶想学编程。不知道从哪开始学起呢? |
B9层 发表时间: 11/26 17:14 |
![]() | 回复: shesh [shesh] ![]() |
登录 |
我日,取款机的程序都不是C系列的. 至少我开没看见过. |
B10层 发表时间: 11/26 21:43 |
![]() | 回复: ceo_8008 [ceo_8008] ![]() |
登录 |
郁闷・・・ 银行是那么脆弱??? |
B11层 发表时间: 11/27 00:52 |
![]() | 回复: pandahacker [pandahack] ![]() |
登录 |
我倒!银行的人又不是吃屎长大的!子木:哥们支持你。希望在多发些好的源程序。 |
B12层 发表时间: 11/27 18:39 |
![]() | 回复: zhoen889 [zhoen889] ![]() |
登录 |
如果用数据库做,在用windows的界面高一下,会更好啊!!! |
B13层 发表时间: 11/27 18:56 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号