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写错了...还有!= 忘了写! 等等.. 以上程序可以运则喊伏行了
#include <stdio.h>
int main (void)
{
int i,g,q=10000,qq=0,z
char mm[6]
const char MM[6]="123456"
printf ("\n\t请输入密码以登入州迹租账户:")
while(1)
{
for(i=0i<6i++)
{
mm[i]=getch()
if (mm[i]!='\b')
{
putchar ('*')
}
else
{
printf ("\b \b")
i--
i--
}
if (mm[i]=='\r')
{
printf ("\b \b")
break
}
}
if (strcmp(mm,MM)==0)
{
printf ("州燃\n\t密码正确!登入银行账户!\n")
printf ("\t[1]查询余额\t[2]取钱\n\t选项:")
scanf ("%d",&g)
switch (g)
{
case 1:printf ("\t你的余额剩余%d元\n",q-qq)break
case 2:printf ("\请输入提取金额:")scanf ("%d",&qq)printf ("\t提取现金%d元\n",qq)break
default:printf ("\t选项错误!\n")break
}
break
}
else
{
printf ("\n密码错误!\n")
printf ("请重新输入密码:")
}
}
}
本来是想来个简单的结果看到楼下说要登入这些功能。。。
这是简单的
#include <stdio.h>int main (void)
{
double a=10000
int i
printf ("请输入你要提取的金额:")
scanf ("%d",&i)
printf ("您的账户余额:%g元",a-i)
return 0
}
再来个稍难得吧。。。
#include <stdio.h>int main (void)
{
char mm[6]
double a=10000
int i=0,g
printf ("[1]取款[2]查询余额:")
scanf ("%d",&g)
switch (g)
{
case 1:printf ("请输入提取金额:")scanf ("%d",&i)printf ("账户余额%g",a-i)break
case 2:printf ("账户余额%g",a-i)break
default:printf ("选项错误!\n")break
}
return 0
}
从编译器复制下来的册兆代码中文都要乱码。。。
#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("请按任意键返回...")
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)