麻烦大家帮忙看看这个程序到底有什么问题,新手菜鸟一枚请大神们多指教!
#include <stdio.h>#include <string.h>
#include <windows.h>
typedef enum proptype{Weapon,Armor,Con,Card,Frage }PropType; //游戏道具枚举
typedef struct _prop{
int id;
char name[50];
int leve;
int stock; //道具的库存数量
PropType type;
double price;
union{
int minAttack;
int minDefence;
int minPower; };
union{
int maxAttack;
int maxDefence;
int maxPower; };
char desc[200];
}Prop; //游戏道具,武器防具,消耗品,卡片
void init(); //初始化游戏环境
void show(); //显示全局数据
Prop propArray[] = {{1,"帝皇天烈剑",1,50,5000,Weapon,.minAttack=1,.maxAttack=4,"传说中的神器"},
{2,"帝皇天烈盾",2,50,7000,Armor,.minDefence=2,.maxDenfence=6,"取日月之精华"},
{3,"玉液琼浆",3,50,15000,Con,.minPower=100,.maxPower=500,"皇帝专用"}};
void show()
{ int i;
int propCount = sizeof(propArray)/sizeof(Prop);
for(i=0;i<propCount;i++)
{
printf("%d\t%s\t%.0lf\n",propArray[i].id,propArray[i].name,propArray[i].price);
switch(propArray[i].type)
{
case Weapon:
printf("最小攻击力:%d\t最大攻击力:%d\t",propArray[i].minAttack,propArray[i].maxAttack);
break;
case Armor:
printf("最小防御力:%d\t最大防御力:%d\t",propArray[i].minDefence,propArray[i].maxDefence);
break;
}
}
}
int main()
{
show();
return 0;
}