求大神帮忙改改,我怎么改都改不好。录入信息后去修改,查询,显示,统计都只能修改,查询,显示和统计最后一个录入的数据。要怎么改好 ?
#include<stdio.h>struct student
{
int bianhao;
char name[20];
char zhonglei;
int shuliang;
char time[20];
char add[20];
}a[100];
int main()
{
void luru();
void chaxun();
void xiugai();
void xianshi();
int tongji();
int i;
do
{
printf("1.录入信息\n");
printf("2.信息修改\n");
printf("3.信息查询\n");
printf("4.信息显示\n");
printf("5.信息统计\n");
printf("6.退出\n");
scanf("%d",&i);
switch(i)
{
case 1:luru();break;
case 2:xiugai();break;
case 3:chaxun();break;
case 4:xianshi();break;
case 5:tongji();break;
case 6:printf("退出\n");break;
default:printf("enter data error!\n");
}
}
while(i!=6);
}
void luru()
{
int i,y;
printf("编号:客户姓名:订餐种类:订餐数量:送餐时间:送餐地址:\n");
for (i=0;i<100;i++){
for(;y!=0;){
scanf("%d %s %c %d %s %s",&a[i].bianhao,&a[i].name,&a[i].zhonglei,&a[i].shuliang,&a[i].time,&a[i].add);
printf("输入“1”继续录入,输入“0”结束录入\n");
scanf("%d",&y);
}}}
void chaxun()
{
int i,bianhao;
printf("请输入编号:");
scanf("%d",&bianhao);
printf("编号:客户姓名:订餐种类:订餐数量:送餐时间:送餐地址:\n");
for (i=0;i<100;i++){
if (bianhao==a[i].bianhao){
printf("%d,%s,%c,%d,%s,%s\n",a[i].bianhao,a[i].name,a[i].zhonglei,a[i].shuliang,a[i].time,a[i].add);
}}}
void xiugai()
{
int i,bianhao;
printf("请输入编号:");
scanf("%d",&bianhao);
printf("编号:客户姓名:订餐种类:订餐数量:送餐时间:送餐地址:\n");
for (i=0;i<100;i++){
if (bianhao==a[i].bianhao){
printf("%d,%s,%c,%d,%s,%s\n",a[i].bianhao,a[i].name,a[i].zhonglei,a[i].shuliang,a[i].time,a[i].add);
printf("编号修改为:客户姓名修改为:订餐种类修改为:订餐数量修改为:送餐时间修改为:送餐地址修改为:\n");
scanf("%d %s %c %d %s %s",&a[i].bianhao,&a[i].name,&a[i].zhonglei,&a[i].shuliang,&a[i].time,&a[i].add);
}}}
void xianshi()
{
int i;
for(i=0;i<100;i++){
if(a[i].bianhao!=0){
printf("编号:客户姓名:订餐种类:订餐数量:送餐时间:送餐地址:\n");
printf("%d,%s,%c,%d,%s,%s\n",a[i].bianhao,a[i].name,a[i].zhonglei,a[i].shuliang,a[i].time,a[i].add);}}}
int tongji()
{
int i,zh,t,A,B,C,shuliang;
char zhonglei;
zh=0,A=0,B=0,C=0;
for(i=0;i<100;i++){
if(a[i].zhonglei=='a')
{t=a[i].shuliang;A=A+t;zh=zh+t*15;}
if(a[i].zhonglei=='b')
{t=a[i].shuliang;B=B+t;zh=zh+t*18;}
if(a[i].zhonglei=='c')
{t=a[i].shuliang;C=C+t;zh=zh+t*23;}}
printf("订a套餐的数量为:%d\n订b套餐的数量为:%d\n订c套餐的数量为:%d\n",A,B,C);
printf("总金额为:%d\n",zh);}