汽车销售管理系统实现不了,跪求高手解答!!!
#include<stdio.h>#include<string.h>
#define N 3
struct car
{
char brand[20];
char name[20];
int price;
int color;
char service;
int stock;
int speed;
char isure;
};
typedef struct car CAR;
void menu();
void InputInfor(CAR x[]);
void ShowInfor(CAR x[]);
void SeekByBrand(CAR x[],char b[]);
void SeekBySpeed(CAR x[],int k1,int k2);
void menu()
(
printf("************************************");
printf("* 汽车销售管理系统 *\n");
printf("* 1.产品种类 *\n");
printf("* 2.产品品牌 *\n");
printf("* 3.产品价格 *\n");
printf("* 4.产品颜色 *\n");
printf("* 5.产品库存 *\n");
printf("* 6.产品服务 *\n");
printf("* 7.产品速度 *\n");
printf("* 8.产品保险 *\n");
printf("* 0.Exit(0) *\n");
printf("*** 请输入你的选择 ***");
printf("**********************************\n");
}
void InputInfor(CAR x[])
{
int i;
for(i=0;i<N;i++)
{
printf("No.[%d]:\n",i+1);
printf("BRAND:"); gets(x[i].brand);
printf("NAME:"); gets(x[i].name);
printf("PRICE:"); scanf("%d",&x[i].price);
printf("COLOR:"); scanf("%d",&x[i].color);
printf("SERVICE:"); gets(x[i].service);
printf("STOCK:"); scanf("%d",&x[i].stock);
printf("SPEED:"); scanf("%d",&x[i].speed);
printf("INSURE:"); gets(x[i].insure);
fflush(stdin);
}
}
void ShowInfor(CAR x[])
{
int i;
for(i=0;i<N;i++)
{
printf("No.[%d]:\n",i+1);
printf("BRAND:%s\n",x[i].brand);
printf("NAME:%s\n",x[i].name);
printf("PRICE:%d\n",x[i].price);
printf("COLOR:%d\n",x[i].color);
printf("SERVICE:%s\n",x[i].service);
printf("STOCK:%d\n",x[i].stock);
printf("SPEED:%d\n",x[i].speed);
printf("INSURE:%s\n",x[i].insure);
}
}
void SeekByBrand(CAR x[],char b[])
{
int i,flag=0;
for(i=0;i<N;i++)
{
if(strcmp(x[i].brand,b)==0)
flag=1;
}
if(flag)printf("找到%s品牌!\n",b);
else printf("没有找到%s品牌!\n",b);
}
void SeekBySpeed(CAR x[],int k1,int k2)
{
int t,i,flag=0,count=0;
if(k1>k2){t=k1;k1=k2;k2=t;}
for(i=0;i<N;i++)
{
if(x[i].speed>=k1 && x[i].speed<=k2)
{
flag=1;
puts(x[i].brand);
count++;
}
}
if(flag)printf("找到速度在%d-%d之间的车%d辆!\n",k1,k2,count);
else printf("没找到速度在%d-%d之间的车!\n",k1,k2);
}
int main()
{
CAR c[N]=
{
{"BENZ","C300",85万,1,Level 1 sales,500,240,honored},
{"BMW","X5",126万,3,Very good,1200,270,honored},
{"HON","CIVIC",40万,2,fine,340,180,honored},
{"NDA","CPPC",42万,2,fine,500,290,honored},
{"HOMA","COOl",50万,2,fine,390,540,honored},
{"JKLA","SXOC",49万,2,fine,720,360,honored},
{"HTOB","QUH",90万,2,fine,600,280,honored},
{"HIRA","GNYT",140万,2,fine,440,580,honored},
{"PDFG","IVI",78万,2,fine,320,180,honored},
};
//InputInfof(c);
ShowInfor(c);
SeekByBrand(c,"CHERRY");
SeekBySpeed(c,200,300);
return 0;
}
[ 本帖最后由 追忆辅助 于 2012-5-15 11:47 编辑 ]