1. 用c语言编程ATM的简单取款过程,越简单越好
#include<stdio.h>
intmain(void)
{
inti,g,q=10000,qq=0,z;
charmm[6];
constcharMM[6]="123456";
printf(" 请输入密码以登入账户:");
while(1)
{
for(i=0;i<6;i++)
{
mm[i]=getch();
if(mm[i]!='')
{
putchar('*');
}
else
{
printf("");
i--;
i--;
}
if(mm[i]==' ')
{
printf("");
break;
}
}
if(strcmp(mm,MM)==0)
{
printf(" 密码正确!登入银行账户! ");
printf(" [1]查询余额 [2]取钱 选项:");
scanf("%d",&g);
switch(g)
{
case1:printf(" 你的余额剩余%d元 ",q-qq);break;
case2:printf("请输入提取金额:");scanf("%d",&qq);printf(" 提取现金%d元 ",qq);break;
default:printf(" 选项错误! ");break;
}
break;
}
else
{
printf(" 密码错误! ");
printf("请重新输入密码:");
}
}
}
本来是想来个简单的结果看到楼下说要登入这些功能。。。
这是简单的
#include<stdio.h>
intmain(void)
{
doublea=10000;
inti;
printf("请输入你要提取的金额:");
scanf("%d",&i);
printf("您的账户余额:%g元",a-i);
return0;
}
再来个稍难得吧。。。
#include<stdio.h>
intmain(void)
{
charmm[6];
doublea=10000;
inti=0,g;
printf("[1]取款[2]查询余额:");
scanf("%d",&g);
switch(g)
{
case1:printf("请输入提取金额:");scanf("%d",&i);printf("账户余额%g",a-i);break;
case2:printf("账户余额%g",a-i);break;
default:printf("选项错误! ");break
}
return0;
}
从编译器复制下来的代码中文都要乱码。。。
2. 简单的C语言模拟ATM取款机问题(大虾帮帮忙!)
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
void LanguageMenu();
void MainMenu();
void Query(float*);
void Deposite(float*);
void WithDraw(float*);
float a=1000;
void LanguageMenu()
{
printf("1 中文\n");
printf("2 English\n");
printf("3 退出\\Exit");
switch(getch())
{
case '1':MainMenu();break;
case '2':MainMenu();break;
default:break;
}
}
void MainMenu()
{
system("cls");
printf("1 查询\n");
printf("2 存款\n");
printf("3 取款\n");
printf("4 退出\n");
switch(getch())
{
case '1':Query(&a);break;
case '2':Deposite(&a);break;
case '3':WithDraw(&a);break;
default: system("cls");return;
}
}
void Query(float *p)
{
system("cls");
printf("此账户中钱数为:¥ %-.2f",*p);
printf("请按任意键继续...");
getch();
}
void Deposite(float *p)
{
float mon;
printf("请输入您要存入的钱数:¥ ");
scanf("%f",&mon);
*p += mon;
printf("存款成功,请按任意键继续...");
}
void WithDraw(float *p)
{
float mon;
printf("请输入您要取出的钱数:¥ ");
scanf("%f",&mon);
if(mon>*p)
printf("对不起,您账户上的钱数不足。\n请按任意键继续...");
else
{
*p -= mon;
printf("取款成功,请按任意键继续...");
getch();
}
}
void main()
{
LanguageMenu();
}
3. 用C语言写一个类似于ATM机的程序,有开户(姓名,密码),存款,取款,查询余额,转账的功能,
packagecom.efounder.pub.util;
importjava.util.ArrayList;
importjava.util.Vector;
/**
*字符串处理工具类
*@authorxiewan
*/
publicclassStringFunction{
(String[]stringArray,charsymbol){
StringBuffersb=newStringBuffer();
for(inti=0;i<stringArray.length;i++){
sb.append(stringArray[i]);
sb.append(symbol);
}
returnsb.toString();
}
publicstaticString[](Stringstring,Stringsymbol){
VectorstringVector=(string,symbol);
String[]stringArray=newString[stringVector.size()];
for(inti=0;i<stringVector.size();i++)
stringArray[i]=(String)(stringVector.elementAt(i));
returnstringArray;
}
publicstaticString[]NO(Stringstring,Stringsymbol){
VectorstringVector=NO(string,symbol);
String[]stringArray=newString[stringVector.size()];
for(inti=0;i<stringVector.size();i++)
stringArray[i]=(String)(stringVector.elementAt(i));
returnstringArray;
}
publicstaticVector(Stringstring,Stringsymbol){
VectorstringVector=newVector();
String[]array=string.split(symbol);
for(inti=0;i<array.length;i++){
stringVector.addElement(array[i]);
}
returnstringVector;
}
publicstaticVectorNO(Stringstring,Stringsymbol){
VectorstringVector=newVector();
String[]array=string.split(symbol);
for(inti=0;i<array.length;i++){
stringVector.addElement(array[i]);
}
returnstringVector;
}
(VectorstringVector,charsymbol){
StringBuffersb=newStringBuffer();
for(inti=0;i<stringVector.size();i++){
sb.append(stringVector.elementAt(i));
sb.append(symbol);
}
returnsb.toString();
}
publicstaticStringfillString(StringpsStr,charpsC,intpsLen){
if(psStr.length()>psLen){
returnpsStr.substring(0,psLen);
}else{
char[]vcTemp=newchar[psLen];
for(inti=0;i<psLen;i++){
vcTemp[i]=psC;
}
StringvsTemp=newString(vcTemp);
StringvsResult=psStr.concat(vsTemp);
returnvsResult.substring(0,psLen);
}
}
publicstaticStringformatValue(doublevalue,intsep,charch,intround){
return"";
}
publicstaticStringGB2Uni(Stringoriginal){
if(original!=null){
try{
returnnewString(original.getBytes("GBK"),"ISO8859_1");
}catch(Exceptione){
e.printStackTrace();
returnnull;
}
}else
returnnull;
}
publicstaticStringUni2GB(Stringoriginal){
if(original!=null){
try{
returnnewString(original.getBytes("ISO8859_1"),"GBK");
}catch(Exceptione){
e.printStackTrace();
returnnull;
}
}else
returnnull;
}
publicstaticStringgenerateID(Stringpre,intvalue,intnum){
charchs[]=newchar[num];
for(inti=0;i<num;i++){
chs[num-i-1]=(char)(48+value%10);
value=value/10;
}
returnpre.trim()+newString(chs);
}
publicstaticStringgetTempStr(){
returnString.valueOf(System.currentTimeMillis());
}
(StringpsStr,StringpsS){
intviPos=psStr.indexOf(psS);
returnviPos>=0;
}
(StringpsStr,StringpsS,StringpsD){
intviPos=psStr.indexOf(psS);
if(viPos<0)
returnpsStr;
intviLength=psS.length();
StringBuffervsValue=newStringBuffer();
while(viPos>=0){
vsValue.append(psStr.substring(0,viPos));
vsValue.append(psD);
psStr=psStr.substring(viPos+viLength);
viPos=psStr.indexOf(psS);
}
vsValue.append(psStr);
returnvsValue.toString();
}
publicstaticString[]splitStringByToken(StringvsStr,Stringsymbol){
StringvsString[]={"",""};
intviPos1;
viPos1=vsStr.indexOf(symbol);
if(viPos1<0){
vsString[0]=vsStr;
vsString[1]="";
returnvsString;
}
vsString[0]=vsStr.substring(0,viPos1);
vsString[1]=vsStr.substring(viPos1+symbol.length(),vsStr.length());
returnvsString;
}
(Stringstring,Stringsymbol){
VectorstringVector=newVector();
StringvsStr=string.trim();
StringvsTemp=null;
String[]st=null;
while((!vsStr.equals(""))&&isIncludeString(vsStr,symbol)){
st=splitStringByToken(vsStr,symbol);
vsTemp=st[0].trim();
if(!vsTemp.equals(""))
stringVector.addElement(vsTemp);
vsStr=st[1].trim();
}
if(!vsStr.equals(""))
stringVector.addElement(vsStr);
returnstringVector;
}
publicstaticStringgetTempStr(intlength){
Stringstr=String.valueOf(System.currentTimeMillis());
returnstr.substring(str.length()-length);
}
WithNull(Stringstring,Stringsymbol){
VectorstringVector=newVector();
StringvsStr=string.trim();
StringvsTemp=null;
String[]st=null;
while((!vsStr.equals(""))&&isIncludeString(vsStr,symbol)){
st=splitStringByToken(vsStr,symbol);
vsTemp=st[0].trim();
stringVector.addElement(vsTemp);
vsStr=st[1].trim();
}
if(!vsStr.equals(""))
stringVector.addElement(vsStr);
returnstringVector;
}
(StringBm,intJs,StringStruct){
inti,Len,Length;
Len=Bm.length();
Length=GetStructLength(Struct,Js);
if(Len>=Length){
Bm=Bm.substring(0,Length);
}
returnBm;
}
(StringBm,StringStruct){
inti,Len,Length;
Len=Bm.length();
Length=GetStructLength(Struct,0);
for(i=0;i<Length-Len;i++){
Bm+="0";
}
returnBm;
}
(Stringcode,Stringstruct){
intcodeLength=code.length();
intstructLength=struct.length();
inttempLength=0;
for(intjs=1;js<=structLength;js++){
tempLength=GetStructLength(struct,js);
if(codeLength==tempLength)
returnjs;
}
return0;
}
(StringStruct,intJS){
inti,Length=0;
Stringsub;
Integerii;
if(JS==0)
JS=Struct.trim().length();
for(i=0;i<JS;i++){
sub=Struct.substring(i,i+1).trim();
ii=Integer.decode("0x"+sub);
//Length+=Integer..parseInt(sub);
Length+=ii.intValue();
}
returnLength;
}
(StringBM,StringStruct,intSJS){
StringRes="";
intLen;
Len=GetStructLength(Struct,SJS);
if(BM.length()>=Len)
Res=BM.substring(0,Len);
returnRes;
}
(intnum,intleng){
returnFillTagFromBegin(String.valueOf(num),leng,"0");
}
(Stringnum,intleng,StringTag){
StringRes="",tempStr1="",tempStr2="";
tempStr1=String.valueOf(num);
for(inti=0;i<(leng-tempStr1.length());i++){
tempStr2+=Tag;
}
Res=tempStr2+tempStr1;
returnRes;
}
publicstaticStringClearBMZero(StringBM,StringBMStruct){
returnClearBMTag(BM,BMStruct,"0");
}
publicstaticStringClearBMTag(StringBM,StringBMStruct,StringTag){
intJSLen=BMStruct.length();
Stringbm="",ZERO,Tmp;
intLen;
for(inti=1;i<=JSLen;i++){
Tmp=BMStruct.substring(i-1,i);
Len=Integer.parseInt(Tmp);
ZERO=RepeatChar(Tag,Len);
if(!BM.startsWith(ZERO)){
bm+=BM.substring(0,Len);
BM=BM.substring(Len);
}else
break;
}
returnbm;
}
publicstaticStringRepeatChar(Stringc,intlen){
StringRes="";
for(inti=0;i<len;i++){
Res+=c;
}
returnRes;
}
/**
*key1=value1;key2=value2;key3=value3
*
*@paraminputStringString
*@paramhashMapMap
*/
(StringinputString,java.util.MaphashMap){
String[]keyValues=StringFunction.NO(inputString,";");
String[]keyValue;
Stringkey,value;
for(inti=0;i<keyValues.length;i++){
if(!"".equals(keyValues[i])){
keyValue=StringFunction.NO(keyValues[i],"=");
if(keyValue.length<2)
continue;
key=keyValue[0];
value="";
for(intk=1;k<keyValue.length;k++){
value+=keyValue[k];
}
hashMap.put(key,value);
}
}
}
/**
*
*@paramhashMap
*Map
*@returnString
*/
(java.util.MaphashMap){
Object[]keys=hashMap.keySet().toArray();
Stringkey,value,keyValue="";
for(inti=0;i<keys.length;i++){
key=(String)keys[i];
value=(String)hashMap.get(key);
keyValue+=key+"="+value+";";
}
if(keyValue.length()>0){
keyValue=keyValue.substring(0,keyValue.length()-1);
}
returnkeyValue;
}
/**
*
*@paramvalue
*String
*@parammark
*String
*@returnString[]
*/
publicstaticString[]split(Stringvalue,Stringmark){
intindex=value.indexOf(mark);
java.util.Listlist=newArrayList();
while(index>=0){
list.add(value.substring(0,index));
value=value.substring(index+mark.length());
index=value.indexOf(mark);
}
list.add(value);
String[]rtn=newString[list.size()];
System.array(list.toArray(),0,rtn,0,rtn.length);
returnrtn;
}
publicstaticvoidmain(String[]args){
Stringvalue="a;;;;";
String[]rtn=split(value,";;");
System.out.println(rtn);
}
}
4. 怎样用c语言编写ATM系统
真正的ATM系统不可能只是用C语言编写的,它应该是一套完整独立的系统,核心代码更机密,不会轻易的泄露。
C语言可以写一个类似于ATM系统的框架,用以模拟ATM机上的各种操作。
框架代码如下:
#include<iostream.h>
#include<stdio.h>
intmain()
{
intchoice=-1;
while(1){
printf("请选择 1.login 2.regist ");
scanf("%d",&choice);
switch(choice){
case1:
login();
break;
case2:
regist();
break;
default:
printf("输入有误,重新输入 ");
break;
}
}
return0;
}
voidlogin(){
printf("INLOGIN ");
intflag=-1;
intX=-1;
printf("输入账户和密码 ");
flag=search();
if(falg==1){
printf("存在,进入主页面 ");
X=menu();
if(X==1)
return;
}
elseif(flag==0){
printf("账户或密码错误 ");
return;
}
}
intregist(){
printf("INREGIST ");
return1;
}
intmenu(){
printf("INMENU ");
intkey=-1;
intN=-1;
while(1){
printf("请选择业务:1.refer 2.deposit 3.withdraw 4.transfer 5.resetPW 6.退出 ");
scanf("%d",&key);
switch(key){
case1:
N=refer();
break;
case2:
N=deposit();
break;
case3:
N=withdraw();
break;
case4:
N=transfer();
break;
case5:
N=resetPW();
break;
case6:
N=6;
return1;
break;
default:
printf("输入有误,重新选择: ");
break;
}
if(N%2==0){
printf("Error! ");
}
}
}
intrefer(){
printf("INREFER ");
//输出余额
return1;
}
intdeposit(){
printf("INDEPOSIT ");
//存钱
return3;
}
intwithdraw(){
printf("INWITHDRAW ");
//取钱
return5;
}
inttransfer(){
ptintf("INTRANSFER ");
//转账
return7;
}
intresetPW(){
prtintf("INRESETPW ");
//重设密码
return9;
}
5. 用C语言一个ATM取款机的程序代码(用循环语句)
/*初始密码和账号都为:123456 */
#include<stdio.h>
int chaxun(int a3)
{
int b;
b=a3;
printf("你的余额为:%d\n",b) ;
}
int qukuan(int a3)
{
int a,b;
printf("请输入您要提取的现金:\n");
scanf("%d",&a);
b=a3-a;
if(b<0)
printf("对不起 ,你的余额不足\n");
else
{
printf("请收好您的%d元现金\n",a);
a3=a3-a;
}
return (a3);
}
int gaini(int a2)
{
int a,b,c=1,d,e=1;
while(e)
{
printf("请输入你的旧密码:\n");
scanf("%d",&d);
if(d==a2)
e=0;
else
{
e=1;
printf("你输入的密码错误,请重新输入:\n");
}
}
while(c)
{
printf("请输入您的六位数新密码\n");
scanf("%d",&a2);
printf("请确认您的六位数新密码\n");
scanf("%d",&b);
if(a2==b)
{
if(b>100000&&b<999999&&b/(b/100000)!=111111)
{
c=0;
printf("密码修改成功\n");
}
else
{
printf("您输入的密码不符合要求,请从新输入\n");
c=1;
}
}
else
{
c=1;
printf("您两次输入的密码不一致,请重新输入:\n");
}
}
return a2;
}
int quka()
{
printf("\n 梦若保保提醒您\n");
printf("请收好您的卡片,谢谢,再见\n\n");
}
int cunkuan(int a3)
{
int i,j,k;
printf("请输入你要存的金额\n");
scanf("%d",&k);
if(k<0)
{
printf("对不起,没有负存款\n");
}
else
{
printf("\n您好,您已经存进去了%d元\n",k);
a3=a3+k;
}
return a3;
}
main()
{
int i,j,b=1,c,k,l,m,n;
int a1=123456,a2=123456,a3=1000;
printf("欢迎使用自动柜员机:\n\n");
while(b==1)
{
printf("请输入您的账号:\n");
scanf("%d",&k);
printf("请输入您的密码:\n");
scanf("%d",&l);
if(k==a1&&l==a2)
{
b=0;
printf("您的账户余额为:%d\n",a3);
}
else
{
b=1;
printf("对不起,您输入的账号或者密码有误,请重新输入:\n");
}
}
do
{
printf("\n请选择您要的服务项目:\n");
printf("1.查询余额\n");
printf("2.取款\n");
printf("3.修改密码\n");
printf("4.取卡\n");
printf("5.存款\n");
scanf("%d",&c);
switch(c)
{
case 1:
chaxun(a3);
break;
case 2:
a3=qukuan(a3);
break;
case 3:
a2=gaini(a2);
break;
case 4:
quka();
break;
case 5:
a3=cunkuan(a3);
break;
}
}while(c!=4);
}
6. c语言ATM取款机怎么做 ,得输入密码的那种
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<conio.h>
void
sys(const
char
*ex)
{
printf(ex);
fflush(stdin);
getch();
}
struct
atm
{
float
money;
char
card[20];
char
pass[20];
};
struct
atm
*creat()
{
struct
atm
*p;
p=(struct
atm
*)malloc(sizeof(struct
atm));
printf("请输入密码:");
gets(p->pass);getchar();
printf("请输入卡号:");
gets(p->card);getchar();
printf("卡号为=%s,密码为=%s\n",p->card,p->pass);
printf("请输入预存款金额:");
scanf("%f",&p->money);
return
p;
}
struct
atm
*qukuan(struct
atm
*p)
{
float
money;
printf("请输入取款金额:");
scanf("%f",&money);
if(money>p->money){printf("余额不足!\n");return
p;}
p->money-=money;
return
p;
}
void
print(struct
atm
*p)
{
printf("当前余额为%.2f,可取款金额为%d\n",p->money,floor(p->money)/100);
}
int
yanzheng(struct
atm
*p)
{
char
pass[20];
printf("你好,请输入密码:");
gets(pass);
if(strcmp(pass,p->pass)==0)
return
1;
return
0;
}
void
main()
{
struct
atm
*p;
int
t=0;
p=creat();
do
t++;
while(!yanzheng(p)&&t<3);
if(t==3){printf("密码连续三次输入错误,退出程序!\n");return
1;}
while(1)
{
system("cls");
printf("****欢迎您使用ATM取款机!****\n");
printf("1:\t取款\n");
printf("2:\t查看余额\n");
printf("0:\t退出\n");
printf("请选择:");
scanf("%d",&t);
fflush(stdin);
switch(t)
{
case
1:qukuan(p);break;
case
2:print(p);break;
}
if(!t)
{
sys("请按任意键退出...");
break;
}
sys("请按任意键返回...");
}
}
7. 用c语言编写ATM的程序,实现开户、存款、取款、查询余额、转账的业务逻辑。
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
void regist();
void login();
void quite();
void inputpassword(char mima[]);
void service();
struct bank
{
char name[20];
char password[7];
int account;
double money;
}kehu;
int find;
int a[10];
struct bank one;
FILE *fp;
void main()
{
int i;
int t=1;
for(i=0;i<100;i++)
{
printf("\t\t\t\t\t\t欢迎使用青软ATM系统\n");
printf("\t\t\t\t\t\t正在进入主界面,请稍等");
int j;
for(j=1;j<t;j++)
{
printf(".");
}
t++;
if(t==10)
{
t=1;
}
printf("\n\t\t\t\t\t\t%d%%",i);
system("cls");
}
while(1)
{
printf("\t\t\t\t\t\t服务类型: \n");
printf("\t\t\t\t\t\t[a]: 用户注册\n");
printf("\t\t\t\t\t\t[b]: 用户登录\n");
printf("\t\t\t\t\t\t[c]: 退出系统\n");
printf("\t\t\t\t\t\t请选择服务: ");
fflush(stdin);
char xz;
scanf("%c",&xz);
if(xz=='a'||xz=='A')
{
regist();
} else if (xz=='b'||xz=='B')
{
login();
} else if(xz=='c'||xz=='C')
{
quite();
} else
{
printf("输入有误,请重新输入");
}
getch();
system("cls");
}
}
void inputpassword(char mima[])
{
int i=0;
char ch;
while(1)
{
ch=getch();
if(ch!='\r')
{
if(ch!='\b'){
mima[i]=ch;
i++;
printf("*");
}else{
if(i>0){
i--;
printf("\b \b");
}
}
}else{
break;
}
}
mima[i]='\0';
printf("\n");
}
void regist()
{
fp=fopen("atm.txt","ab+");
if(fp==NULL)
{
printf("\n\t\t\t文件打开失败!");
return;
}
system("cls");
printf("\t\t\t现在执行的是注册函数的使用\n");
printf("\t\t请输入用户名: ");
fflush(stdin);
gets(kehu.name);
char password1[7];
while(1)
{
while(1)
{
printf("\n\n\t\t请输入密码:");
fflush(stdin);
inputpassword(kehu.password);
int n=strlen(kehu.password);
if(n==6)
{
break;
}else
{
printf("\n\t\t密码必须为6位!");
}
}
printf("\n\t\t请输入正确密码!: ");
fflush(stdin);
inputpassword(password1);
if(strcmp(kehu.password,password1)==0)
{
break;
}else{
printf("\n\n\t\t两次密码必须相同!");
}
}
rewind(fp);
struct bank k;
if(fread(&k,sizeof(struct bank),1,fp)==1)
{
fseek(fp,-sizeof(k),2);
fread(&k,sizeof(k),1,fp);
kehu.account=k.account+1;
}else{
kehu.account=20170001;
}
kehu.money=0;
fseek(fp,0,2);
fwrite(&kehu,sizeof(struct bank),1,fp);
fclose(fp);
printf("\n\n\t\t开户成功! ");
printf("\n\t\t您的账号为%d!",kehu.account);
printf("\n\t\t现在请您重新登录!");
}
void searchmoney()
{
system("cls");
printf("您现在使用的是查询余额功能: \n");
printf("\n\n\t\t您的余额是%0.2lf",one.money);
}
void savemoney()
{
system("cls");
double inmoney;
printf("请您选择您要存款的金额 \n");
scanf("%lf",&inmoney);
int q;
int r=1;
for(q=0;q<100;q++)
{
int w;
for(w=1;w<r;w++)
{
printf(".");
}
r++;
if(r==10)
{
r=1;
}
printf("\n\t\t\t\t\t\t正在存款%d%%",q);
system("cls");
}
one.money=one.money+inmoney;
fseek(fp,-sizeof(one),1);
fwrite(&one,sizeof(one),1,fp);
printf("\n\n\t\t\t\t\t\t您已存款成功!");
}
void withdrawalmoney()
{
system("cls");
double outputsomemoney;
printf("请您选择您要取款的金额 \n");
scanf("%lf",&outputsomemoney);
if(one.money<outputsomemoney){
printf("您的余额已不足,请您注意!");
}else {
int q;
int r=1;
for(q=0;q<100;q++)
{
int w;
for(w=1;w<r;w++)
{
printf(".");
}
r++;
if(r==10)
{
r=1;
}
printf("\n\t\t\t\t\t\t正在取款%d%%",q);
system("cls");
}
one.money=one.money-outputsomemoney;
fseek(fp,-sizeof(one),1);
fwrite(&one,sizeof(one),1,fp);
printf("\n\n\t\t\t\t\t\t您已取款成功!请点清钞票!");
printf("\n\n\t\t\t\t\t\t您现在的余额为%lf",one.money);
}
}
void transfermoney()
{
system("cls");
int ifang;
int qian;
fflush(stdin);
printf("\n\n\n\t\t您现在使用的是转账功能");
printf("\n\t\t\t请输入您要转账的账户:");
scanf("%d",&ifang);
int n=ftell(fp);
rewind(fp);
int flag=0;
struct bank temp;
while(fread(&temp,sizeof(temp),1,fp)==1)
{
if(temp.account==ifang)
{
flag=1;
break;
}
}
if(flag==1)
{
printf("请输入转账金额:");
scanf("%d",&qian);
if(one.money>=qian)
{
int q;
int r=1;
for(q=0;q<100;q++)
{
int w;
for(w=1;w<r;w++)
{
printf(".");
}
r++;
if(r==10)
{
r=1;
}
printf("\n\t\t\t\t\t\t正在转账,请稍后!%d%%",q);
system("cls");
}
temp.money=temp.money+qian;
fseek(fp,-sizeof(temp),1);
fwrite(&temp,sizeof(temp),1,fp);
one.money=one.money-qian;
fseek(fp,n-sizeof(one),0);
fwrite(&one,sizeof(one),1,fp);
printf("\n\t\t\t\t转账成功!");
}else{
printf("\n\t\t\t\t您的余额已不足!");
}
}
}
void xiugai(){
system("cls");
printf("\n\n\t\t 现在进行的是修改密码功能\n");
char oldpassword[7];
char newpassword[7];
char newpassword1[7];
int i;
for(i=0;i<3;i++){
printf("\n\t\t\t 请输入旧密码:\n");
inputpassword(oldpassword);
if(strcmp(oldpassword,one.password)==0){
printf("\n\t\t\t 输入成功!\n");
break;
}else{
printf("\n\t\t\t 密码输入有误,请重新输入!\n");
}
}
if(i<3){
while(1){
printf("\n\t\t\t 请输入您的新密码:\n");
inputpassword(newpassword);
printf("\n\t\t\t 请输入您的确认密码:\n ");
inputpassword(newpassword1);
if(strcmp(newpassword,newpassword1)==0){
strcpy(one.password,newpassword);
fseek(fp,-sizeof(one),1);
fwrite(&one,sizeof(one),1,fp);
printf("\n\t\t\t 密码修改成功!");
break;
}else{
printf("\n\t\t\t 两次密码输入不一致!");
}
}
}else{
printf("\n\t\t\t 密码输入错误!");
}
}
int zhuxiaozhanghao()
{
system("cls");
int zhuxiaoxitong;
char sf;
printf("你要注销的账号是%d",one.account);
printf("你是否要对此账号进行注销?\n\n\t\t请您选择:注销(Y)or不注销(N):");
fflush(stdin);
scanf("%c",&sf);
if(sf=='y'||sf=='Y')
{
printf("正在为您注销!\n",one.account);
zhuxiaoxitong=1;
}else{
printf("不注销系统!\n",one.account);
}
return zhuxiaoxitong;
}
void service()
{
while(1){
system("cls");
printf("\n\n\n\t\t\t\t\t\t现在是服务系统,本系统有以下服务");
printf("\n\t\t\t\t\t\t[a] 查询余额\n");
printf("\n\t\t\t\t\t\t[b] 存款服务\n");
printf("\n\t\t\t\t\t\t[c] 转账服务\n");
printf("\n\t\t\t\t\t\t[d] 取款服务\n");
printf("\n\t\t\t\t\t\t[e] 修改密码\n");
printf("\n\t\t\t\t\t\t[f] 注销 \n");
printf("\n\t\t\t\t\t\t[g] 退出系统\n");
char e;
printf("\n\t\t\t\t\t\t您要选择的服务是:");
fflush(stdin);
scanf("%c",&e);
switch(e)
{ case'A':
case'a': searchmoney() ;break;
case'B':
case'b': savemoney() ;break;
case'C':
case'c': transfermoney() ;break;
case'D':
case'd': withdrawalmoney() ;break;
case'E':
case'e': xiugai() ;break;
case'F':
case'f': {int zhuxiaoxitong=zhuxiaozhanghao();{if(zhuxiaoxitong==1) return;}break;}
case'G':
case'g': quite();break;
}
printf("\n\n\n\t\t\t\t按任意键继续......\n");
getch();
}
}
void login()
{
fp=fopen("atm.txt","rb+");
if(fp==NULL)
{
printf("\n\n\n\t\t\t\t文件打开失败!");
return;
}
system("cls");
printf("\n\t\t\t\t\t\t现在执行的是登录函数的使用\n");
int zhanghao;
printf("\n\t\t\t\t\t\t请输入账号:");
scanf("%d",&zhanghao);
int flag=0;
while(fread(&one,sizeof(one),1,fp)==1)
{
if(zhanghao==one.account){
flag=1;
break;
}
}
char password2[7];
if(flag==1){
int h;
for(h=0;h<3;h++){
printf("\n\t\t\t\t\t\t请输入密码:");
fflush(stdin);
inputpassword(password2);
if(strcmp(password2,one.password)==0)
{
printf("\n\t\t\t\t\t\t登陆成功!");
service();
break;
}else{
printf("密码不正确!");
}
}
if(h==3){
printf("\n\t\t\t您的密码三次输入有误,返回");
}
}else{
printf("无此账号!");
}
fclose(fp);
}
void quite()
{
system("cls");
printf("\t\t\t现在执行的是退出函数的使用\n");
exit(0);
}
8. c语言 简单模拟取款机操作 取款金额为2000的确定算法怎么写
如下,实际过程中还需要加个菜单选择,另外要对用户输入进行合法性检查。
#include<stdio.h>
int main()
{
int n;
char ch;
printf("请输入您要取款的金额:");
scanf("%d",&n);
printf("请确认您的取款金额(y 或者n):");
ch = getchar();
if(ch == 'y' && ch =='Y') //这个是你要的算法
printf("取款%d成功\n",n)
//同样的这里可以加入其它的判断,手机打字不便,自己根据需要加。
return 0;
}
9. 在C语言中ATM自动取款机的功能程序怎么写啊
#include<stdio.h>
void main()
{
char SelectKey,CreditMoney,DebitMoney;
while(1)
{
do{
clrscr();
puts("Please select key:");
puts("1.Quary");
puts("2.Credit");
puts("3.Debit");
puts("4.Return");
SelectKey=getch();
}while(SelectKey!='1'&&SelectKey!='2'&&SelectKey!='3'&&SelectKey!='4');
switch(SelectKey)
{
case'1':
clrscr();
puts("Your balance is $1000");
getch();
break;
case'2':
do{
clrscr();
puts("Please select Credit money:");
puts("1.$50");
puts("2.$100");
puts("3.Return");
CreditMoney=getch();
}while(CreditMoney!='1'&&CreditMoney!='2'&&CreditMoney!='3');
switch(CreditMoney)
{
case'1':
clrscr();
puts("Your Credit money is $50,Thank you!");
getch();
break;
case'2':
clrscr();
puts("Your Credit money is $100,Thank you!");
getch();
break;
case'3':
break;
}
break;
case'3':
do{
clrscr();
puts("Please select Debit money:");
puts("1.$50");
puts("2.$100");
puts("3.$500");
puts("4.$1000");
puts("5.Return");
DebitMoney=getch();
}while(DebitMoney!='1'&&DebitMoney!='2'&&DebitMoney!='3'&&DebitMoney!='4'&&DebitMoney!='5');
switch(DebitMoney)
{
case'1':
clrscr();
puts("Your Debit money is $50,Thank you!");
getch();
break;
case'2':
clrscr();
puts("Your Debit money is $100,Thank you!");
getch();
break;
case'3':
clrscr();
puts("Your Debit money is $500,Thank you!");
getch();
break;
case'4':
clrscr();
puts("Your Debit money is $1000,Thank you!");
getch();
break;
case'5':
break;
}
break;
case'4':
return;
}
}
}
几个小错误而已...比如忘了写双撇号,switch写错了...还有!= 忘了写! 等等.. 以上程序可以运行了