n问题: 有时需要将不同类型的数据组合成一个有机的整体,以便于引用。如:一个学生有学号 / 姓名 / 性别 / 年龄 / 地址等属性 int num; char name[20]; char sex; int age; int char addr[30]; 100101 Li Fun M 18 87.5 Beijing num name sex age score addr§12.2§12.2 结构体的定义结构体的定义结构是一种构造数据类型 (“ 结构”是由若干个成员组成的 ) ,在使用之前必须先定义,然后才能用来定义相应的结构体变量、结构体数组、结构体指针变量。结构体类型一般形式: struct 结构体名 { 成员列表 } ;其中各成员都应进行类型说明,即类型名 成员名;例: struct student {int num; char name[20]; char sex; int age; float score; char addr[30]; } ;结构体变量的定义结构体变量的定义(1) 先声明结构类型,再定义结构体变量例: struct student {int num; char name[20]; float score; } ; struct student stu1, stu2;结构体变量的定义结构体变量的定义(2) 在声明结构类型的同时定义结构体变量例: struct student {int num; char name[20]; float score; }stu1, stu2;结构体变量的定义结构体变量的定义(3) 直接定义结构体类型变量例: struct {int num; char name[20]; float score; }stu1, stu2;结构体变量的引用结构体变量的引用 一般对结构体变量的使用,包括赋值、输入、输出、运算等都是通过其成员来实现的。结构体变量成员的表示方法:结构体变量名 . 成员名例: stu1.num ( 学生 1 的学号 ) stu1.score( 学生 1 的分数 )结构体变量的初始化结构体变量的初始化 和其他类型变量一样,定义结构体变量的同时,给它的成员赋初值。例: #include void main( ) {struct student {int num; char name[20]; float score; }stu1={1301,”Zhang San”,82.50}; printf(“No.%d,Name:%s,Score:%f\n”, stu1.num,stu1.name,stu1.score); }结构体变量的赋值结构体变量的赋值 通过输入语句或赋值语句,实现对结构体变量的成员赋值。例: #include void main( ) {struct student {int num; char name[20]; float score; }stu1 ; stu1.num=1301; stu1.name=”Zhang San”; scanf(“%f”,&stu1.score); printf(“No.%d,Name:%s,Score:%f\n”, stu1.num,stu1.name,stu1....