#include<stdio.h>
int main(void)
{
struct goods
{
long int number;
char name[20];
float weight,length,width,hight;
} s[2];
int choice,i;
printf("输入货物的信息:\n");
for(i=0;i<2;i++)
scanf("%ld%s%f%f%f%f",&s[i].number,s[i].name,&s[i].weight,&s[i].length,&s[i].width,&s[i].hight);
for(i=1;i<=2;i++)
{
printf("input [0] select 矿泉水\n");
printf("input [1] select 啤酒\n");
printf("Enter choice:");
scanf("%d",&choice);
if(choice!=0&&choice!=1)
{
printf("sorry 没有你想要查询的货物,请重新输入:");
break;
}
switch(choice)
{
case 1:
printf("%ld %s %0.2fkg %0.2fcm %0.2fcm %0.2fcm\n",s[i].number,s[i].name,s[i].weight,s[i].length,s[i].width,s[i].hight);
break;
case 2:
printf("%ld %s %0.2fcm %0.2fcm %0.2fcm %0.2fcm\n",s[i].number,s[i].name,s[i].weight,s[i].length,s[i].width,s[i].hight);
break;
default:
printf("no");
break;
}
}
printf("thanks\n");
return 0;
}你试试这个程序看是不是你想要的答案