c语言如何动态输入数组,求助~~ 如何把数组变成动态输入的?

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

代码在这里

#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");

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值