数组输出的第一个总是0,求教 下面的是我的代码
#include<stdio.h>char menu[6][8][16]={
{"菜单","开胃菜","主菜","主食","饭后甜点","饮料"},
{"开胃菜","烧椒皮蛋","蓝莓山药墩","竹笋干炒肉","干煎野山菌","小炒黄牛肉"},
{"主菜","菠萝古老肉","水煮鱼","茄汁基围虾","盐焗手撕鸡","红烧黄花鱼","蚝油生菜","金牌蒜香骨"},
{"主食","三鲜水饺","手擀面","米饭"},
{"饭后甜点","草莓奶昔","冰激凌","蛋糕"},
{"饮料","雪碧","蔬菜汁","啤酒","果汁"},
};
double price[6][8]={{0},{0,8,10,8,13,12},{0,15,20,35,30,28,8,18},
{0,15,12,2},{0,10,16,10},{0,5,8,8,8}},caiqian[10];
char menu_()
{
int n;
printf("%s:\n",menu[0][0]);
for(n=1;n<6;n++)
{
printf("%5d.%s\n",n,menu[0][n]);
}
printf(" 0.点餐结束\n请选择:");
}
int num(int i)
{
if(i==1) return 6;
else if(i==2) return 8;
else if(i==3) return 4;
else if(i==4) return 4;
else if(i==5) return 5;
}
int select(int i,int s)
{
int j;
printf(" %d.%s\n",i,menu[i][0]);
for(j=1;j<s;j++)
{
printf("%9d.%-10s%10.2f\n",j,menu[i][j],price[i][j]);
}
printf(" 0.返回\n请选择:");
}
int main()
{
int i,j,s,k,a[5][7]={0},shu[10],zi[10],m=0,n,v=0,z,fen[100];
char c,ch;
for(;;)
{
menu_();
scanf("%s",&c);
if(c=='0') break;
else if(c=='1'||c=='2'||c=='3'||c=='4'||c=='5')
{
i=c-48;
s=num(i);
for(;;)
{
select(i,s);
scanf("%s",&ch);
if(ch=='0') break;
else if(ch=='1'||ch=='2'||ch=='3'||ch=='4'||ch=='5')
{
k=ch-48;
printf("你点的是 %s ,请问要几份:",menu[i][k]);
scanf("%d",&n);
shu[v]=i;
zi[v]=k;
caiqian[v]=price[i][k];
fen[v]=n;//这里我在后面输出的时候第一个数总是0的,我想知道为什么,希望大家帮帮手
v++;
printf("\n");
}
}
}
printf("\n");
}
printf("\n你点的菜菜单:\n 菜名 单价");
printf(" 数量 价格\n");
for(z=0;z<v;z++)
{
printf("%s %s %.2lf %d\n",menu[shu[z]][0],menu[shu[z]][zi[z]],price[shu[z]][zi[z]],fen[z]);
}
printf("---------------------------------------------------------");
printf("\n 总价\n");
return 0;
}