如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
第二讲结构与链表结构类型的引入 structdate //日期结构类型
{intyear;
intmonth;
intday;
};
structstd_info //学生信息结构类型
{charno[7];
charname[9];
charsex[2];
structdatebirthday;
};
structscore //成绩结构类型
{charno[7];
intscore1;
intscore2;
intscore3;
};structdate//日期结构类型
{ intyear;
intmonth;
intday;
};
structyg_info//员工信息类型
{ charno[6];
charname[9];
charsex[2];
structdatebirthday;
charzw[9];
charmar[2];
floatpay;
};几个要注意的问题
类型与变量
结构变量的初始化
结构变量={初值表}
structstd_infostudent={"000102",“angel",“f",{1980,9,20}}
structstd_infostudent={000102,“angel",“f",{1980,9,20}}
成员运算符
student.nostudent.birthday.year
student.birthday.year=2000
gets(student.no)指向结构类型数据的指针
结构变量在内存中的起始地址称为结构变量的指针#include"struct.h"
//定义并初始化一个外部结构数组student
structstd_infostu[3]={{"000102",“john",“m",{1980,5,20}},
{"000105",“apple",“f",{1980,8,15}},
{“000112”,“kitty”,“f”,{1980,3,10}}};
Voidmain()
{structstd_info*p=stu;
for(;p<stu+3;p++)
{printf("%-7s%-9s%-4s",(*p).no,(*p).name,(*p).sex);
printf("%4d-%2d-%2d\n",(*p).birthday.year,
(*p).birthday.month,(*p).birthday.day);
}
}
xx****88
实名认证
内容提供者
最近下载