该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
代码在这里
#include
#include
#include
int card[6][20];
int pass_word(int num)//判断输入卡号
{
int i,j=7;
if(num<0) j=8;
for(i=0;i<6;i++)
if(num==card[i][0]) j=i;
return j;
}
void get_mony(int i) //取款
{
int j,k;
printf("Please input your money:\n\n");
scanf("%d",&j); if(card[i][2]<11)
{
if(j
{
card[i][1]=card[i][1]-j;
card[i][2]=card[i][2]+1;
k=card[i][2]; //交易次数
card[i][k+2]=-j; //存放第i 张卡当日第k次交易的取款金额,负值代表取款 }
else printf("Sorry ! Your balance has been insufficient\n\n");//对不起 您的余额已不足
}
else printf("Sorry Today you have no remaining business times\n");
}
void deposit(int i)//存款
{
int j,k;
printf("Please input your money:\n\n");
scanf("%d",&j);
if(card[i][2]<11)
{
card[i][1]=card[i][1]+j;
card[i][2]=card[i][2]+1;
k=card[i][2]; //交易次数
card[i][k+2]=j; //存放第i 张卡当日第k次交易的存款金额,正值代表存款
}
else printf("Sorry Today you have no remaining business times\n");
}
void money_ck(int i) //余额查询
{
int j=3;
printf("Your balance : %d\n\n",card[i][1]);//剩余余额
printf("Today the number of your trades: %d\n\n",card[i][2]);//已经完成存/取的次数
printf("The remainder number of the trades: %d\n\n",(17-card[i][2]));//每天最多可进行存取一共17次,剩余次数
if (card[i][j]!=0)
{
printf("Your Check list : \n");
printf("Order of trades Amounts\n");//交易次序 交易金额
while(card[i][j]!=0)//存/取列表
{
printf("%8d %d\n",(j-2),card[i][j]);
j++;
}
printf("\n\n");
}
else printf("You didn't take any deal today\n\n");
} void main()
{
int data1,data2;
int i,t;
int data3=1,j=1; card[0][0]=123;
card[0][1]=5000;
card[0][2]=0; card[1][0]=456;
card[1][1]=3500;
card[1][2]=0; card[2][0]=789;
card[2][1]=4000;
card[2][2]=0;
printf("\nWelcome to the industrial and Commercial Bank of China\n\n"); while(data3)
{
printf("If you want to enter the menue,please input 1 :\n");
printf("If you want to quit,please input 0 :\n");
scanf("%d",&t);
if(t==1)
{
printf("Please input your card's number :\n");
scanf("%d",&data1);
data2=pass_word(data1);
if((data2<6)&&(data2>=0))
{
while(j)
{
printf("**************************************\n\n");
printf("Teller ---1 Balance inquiry---2\n\n");//1 取款 2 余额查询
printf("Deposit---3 ESC ---4\n\n"); //3 存款 4 退出操作
printf("**************************************\n\n");
scanf("%d",&i);
switch(i)
{
case 1 : get_mony(data2); //取款
break;
case 2 : money_ck(data2); //余额查询
break;
case 3 : deposit(data2); //取款
break; case 4 : j=0; //结束
break;
default: printf("Sorry Error Operating\n");
break;
}
}
}
}
if(data2==7)//卡号错误处理
{
printf("Sorry card's number is worong\n\n");
}
if(data2==8)//输入负卡号处理
{
printf("Sorry Error Operating\n\n");
data3=0;
}
j=1;
if(t==0)
{data3=0;
break;
}
else
{ printf("Sorry Error Operating\n\n");
}
}
}