练习题一、定义一个结构体Gamer用来存储一个游戏中的角色的信息,包括血值、等级、坐标等信息
要求:
(1) 具体包含哪些信息自由设计
(2) 但这些包含的类型中,必须要有一个成员是结构体类型
struct coordinate
{
float x;
float y;
float h;
};
struct Character_information
{
int Life_value;
int Magic_value;
int Grade;
int Aggressivity;
coordinate position;
char name[20];
};
练习题二、定义一个函数,用来给这个结构体变量赋值.
void Function()
{
tianlong.Life_value = 100;
tianlong.Magic_value = 200;
tianlong.Grade = 10;
tianlong.Aggressivity = 300;
tianlong.position.x = 20.0;
tianlong.position.y = 30.0;
tianlong.position.h = 40.0;
tianlong.Life_value = 100;
}
练习题三、定义一个函数,用来显示这个结构体变量的所有成员信息
void Function1()
{
printf("%d",tianlong.Aggressivity);
printf("%d",tianlong.Grade);
printf("%d",tianlong.Life_value);
printf("%d",tianlong.Magic_value);
printf("%f",tianlong.position.x);
printf("%f",tianlong.position.y);
printf("%f",tianlong.position.h);
}