error C2228: left of '.isempty' must have class/struct/union type 10
#include<stdafx.h>voidint(structGaragegar[][6]){inti,j;for(i=0;i<2;i++){for(j=0;j<6;j...
#include <stdafx.h>
void int(struct Garage gar[][6])
{
int i, j;
for (i=0; i<2; i++)
{
for (j=0; j<6; j++)
{
gar[i][j].lay = i+1;
gar[i][j].garagenum = j+1;
gar[i][j].time = 0;
gar[i][j].isempty = 1;
}
}
for (i=0; i<4; i++)
{
gar[0][i].isempty = 0;
}
strcpy(gar[0][0].carnum, "GF8888");
gar[0][0].time = 20;
strcpy(gar[0][1].carnum, "GF6666");
gar[0][1].time = 15;
strcpy(gar[0][2].carnum, "GF9999");
gar[0][2].time = 10;
strcpy(gar[0][3].carnum, "GF5858");
gar[0][3].time = 5;
}
void AddTime(struct Garage gar[][6])
{
int i, j;
for (i=0; i<2; i++)
{
for (j=0; j<6; j++)
{
if (gar[i][j].isempty == 0)
{
gar[i][j].time += 5;
}
}
}
}
void Park(struct Garage gar[][6])
{
int i;
char num[8];
printf("请输入车牌号:");
scanf("%s", num);
for (i=0; i<6; i++)
{
if (gar[0][i].isempty == 1)
{
printf("第一层第%d号车位空着,请在此处停车\n", i+1);
strcpy(gar[0][i].carnum, num);
printf("车牌号:%s 层号:1 车位号: %d \n", num, i+1);
AddTime(gar);
gar[0][i].isempty = 0;
gar[0][i].time = 5;
return;
}
}
printf("第一层已经没有空车位\n");
for (i=0; i<6; i++)
{
if (gar[1][i].isempty == 1)
{
printf("第二层第%d号车位空着,请在此处停车\n", i+1);
strcpy(gar[1][i].carnum, num);
printf("车牌号:%s 层号:2 车位号: %d \n", num, i+1);
AddTime(gar);
gar[1][i].isempty = 0;
gar[1][i].time = 5;
return;
}
}
printf("对不起,1 2层都没有空车位,您现在不能在此停车\n");
}
void Information(struct Garage gar[][6])
{
int i, j;
printf(" 车牌号 层号 车位号 停车时间\n");
for (i=0; i<2; i++)
{
for(j=0; j<6; j++)
{
if (gar[i][j].isempty == 0)
printf(" %s%8d%8d%8d\n", gar[i][j].carnum, gar[i][j].lay, gar[i][j].garagenum, gar[i][j].time);
}
}
printf("\n");
}
/*取车*/
double Leave(struct Garage gar[2][6])
{
int i, j;
char num[8];
double charge = 0;
printf("请输入要取的车牌号:");
scanf("%s", num);
for (i=0; i<2; i++)
{
for (j=0; j<6; j++)
{
if (!strcmp(gar[i][j].carnum, num))
{
printf("您在%d层%d车位停车%d分钟\n", gar[i][j].lay, gar[i][j].garagenum, gar[i][j].time);
charge = gar[i][j].time/5*0.2;
printf("停车费用为每5分钟0.2元,您需交%.2lf元\n", charge);
gar[i][j].isempty == 1;
return charge;
}
}
}
printf("没有您输入的车号。\n\n");
return charge;
}
/*是否查看总收入*/
void IsPrintTotal(double total)
{
char ch;
printf("是否查看停车收费总计?Y/N");
scanf("%c", &ch);
while (ch!='y' && ch!='Y' && ch!='n' && ch!='N')
{
printf("请输入Y或N ");
scanf("%c", &ch);
printf("\n");
}
switch (ch)
{
case 'Y':
case 'y':
printf("停车收费总计为%.2lf元\n", total);
break;
case 'N':
case 'n':
break;
}
}
/*main()
{
int choice;
double total = 0;
struct Garage gar[2][6];
int(gar); //初始化第一层已经停有的4辆车
while (1)
{
Instruction();
printf("请输入要进行的操作:");
scanf("%d", &choice);
while (choice<0 || choice>3)
{
printf("输入的不合法,请输入0-3选择:");
scanf("%d", &choice);
}
switch (choice)
{
case 1:
Park(gar);
break;
case 2:
total += Leave(gar);
IsPrintTotal(total);
break;
case 3:
Information(gar);
break;
case 0:
exit(0);
}
}
return 0;
}*/
有什么问题?? 展开
void int(struct Garage gar[][6])
{
int i, j;
for (i=0; i<2; i++)
{
for (j=0; j<6; j++)
{
gar[i][j].lay = i+1;
gar[i][j].garagenum = j+1;
gar[i][j].time = 0;
gar[i][j].isempty = 1;
}
}
for (i=0; i<4; i++)
{
gar[0][i].isempty = 0;
}
strcpy(gar[0][0].carnum, "GF8888");
gar[0][0].time = 20;
strcpy(gar[0][1].carnum, "GF6666");
gar[0][1].time = 15;
strcpy(gar[0][2].carnum, "GF9999");
gar[0][2].time = 10;
strcpy(gar[0][3].carnum, "GF5858");
gar[0][3].time = 5;
}
void AddTime(struct Garage gar[][6])
{
int i, j;
for (i=0; i<2; i++)
{
for (j=0; j<6; j++)
{
if (gar[i][j].isempty == 0)
{
gar[i][j].time += 5;
}
}
}
}
void Park(struct Garage gar[][6])
{
int i;
char num[8];
printf("请输入车牌号:");
scanf("%s", num);
for (i=0; i<6; i++)
{
if (gar[0][i].isempty == 1)
{
printf("第一层第%d号车位空着,请在此处停车\n", i+1);
strcpy(gar[0][i].carnum, num);
printf("车牌号:%s 层号:1 车位号: %d \n", num, i+1);
AddTime(gar);
gar[0][i].isempty = 0;
gar[0][i].time = 5;
return;
}
}
printf("第一层已经没有空车位\n");
for (i=0; i<6; i++)
{
if (gar[1][i].isempty == 1)
{
printf("第二层第%d号车位空着,请在此处停车\n", i+1);
strcpy(gar[1][i].carnum, num);
printf("车牌号:%s 层号:2 车位号: %d \n", num, i+1);
AddTime(gar);
gar[1][i].isempty = 0;
gar[1][i].time = 5;
return;
}
}
printf("对不起,1 2层都没有空车位,您现在不能在此停车\n");
}
void Information(struct Garage gar[][6])
{
int i, j;
printf(" 车牌号 层号 车位号 停车时间\n");
for (i=0; i<2; i++)
{
for(j=0; j<6; j++)
{
if (gar[i][j].isempty == 0)
printf(" %s%8d%8d%8d\n", gar[i][j].carnum, gar[i][j].lay, gar[i][j].garagenum, gar[i][j].time);
}
}
printf("\n");
}
/*取车*/
double Leave(struct Garage gar[2][6])
{
int i, j;
char num[8];
double charge = 0;
printf("请输入要取的车牌号:");
scanf("%s", num);
for (i=0; i<2; i++)
{
for (j=0; j<6; j++)
{
if (!strcmp(gar[i][j].carnum, num))
{
printf("您在%d层%d车位停车%d分钟\n", gar[i][j].lay, gar[i][j].garagenum, gar[i][j].time);
charge = gar[i][j].time/5*0.2;
printf("停车费用为每5分钟0.2元,您需交%.2lf元\n", charge);
gar[i][j].isempty == 1;
return charge;
}
}
}
printf("没有您输入的车号。\n\n");
return charge;
}
/*是否查看总收入*/
void IsPrintTotal(double total)
{
char ch;
printf("是否查看停车收费总计?Y/N");
scanf("%c", &ch);
while (ch!='y' && ch!='Y' && ch!='n' && ch!='N')
{
printf("请输入Y或N ");
scanf("%c", &ch);
printf("\n");
}
switch (ch)
{
case 'Y':
case 'y':
printf("停车收费总计为%.2lf元\n", total);
break;
case 'N':
case 'n':
break;
}
}
/*main()
{
int choice;
double total = 0;
struct Garage gar[2][6];
int(gar); //初始化第一层已经停有的4辆车
while (1)
{
Instruction();
printf("请输入要进行的操作:");
scanf("%d", &choice);
while (choice<0 || choice>3)
{
printf("输入的不合法,请输入0-3选择:");
scanf("%d", &choice);
}
switch (choice)
{
case 1:
Park(gar);
break;
case 2:
total += Leave(gar);
IsPrintTotal(total);
break;
case 3:
Information(gar);
break;
case 0:
exit(0);
}
}
return 0;
}*/
有什么问题?? 展开
2个回答
展开全部
关于此错误的详细原因,请参考微软MSDN文档:
http://msdn.microsoft.com/zh-cn/library/3y365xw6.aspx
http://msdn.microsoft.com/zh-cn/library/3y365xw6.aspx
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询