资源预览内容
第1页 / 共57页
第2页 / 共57页
第3页 / 共57页
第4页 / 共57页
第5页 / 共57页
第6页 / 共57页
第7页 / 共57页
第8页 / 共57页
第9页 / 共57页
第10页 / 共57页
亲,该文档总共57页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
,:,9.1 -,9.1.1 ,struct . ,struct, :, struct student int num; char name10; char sex; int age; float score; char addr30; ;, ,struct . struct ,9.2 (1) , struct student int num; char name10; char sex; int age; float score; char addr30; ; struct student stu1,stu2;,(2) ,struct . , struct student int num; char name20; char sex; int age; float score; char addr30; stu1,stu2;,(3) ,struct . , struct int num; char name10; char sex; int age; float score; char addr30; stu1,stu2;, , 1. :棻 : :; :, 2. 3.,9.1.3 , ., struct student int num; char name20; char sex; int age; float score; char addr30; stu1,stu2;,stu1.num=10;,stu1.score=85.5;,stu1.score+=stu2.score; stu1.age+;,() : 1 :, , ,stu1.birthday.month=12;, ,struct . struct =, struct student int num; char name20; char sex; int age; char addr30; ; struct student stu1=112,Wang Lin,M,19, 200 Beijing Road;,struct . =, struct student int num; char name20; char sex; int age; char addr30; stu1=112,Wang Lin,M,19, 200 Beijing Road;,struct . =, struct int num; char name20; char sex; int age; char addr30; stu1=112,Wang Lin,M,19, 200 Beijing Road;,9.2 ,: struct student int num; char name20; char sex; int age; ; struct student stu2;,: struct student int num; char name20; char sex; int age; stu2;,: struct int num; char name20; char sex; int age; stu30;, struct int num; char name20; char sex; int age; stu =,;,: struct student int num; char name10; char sex; int age; ; struct student stu =100,Wang Lin,M,20, 101,Li Gang,M,19, 110,Liu Yan,F,19;, struct student int num; char name10; char sex; int age; float score; stu =,;, .,1 4,struct student int num; char name10; char sex; int age; float score; struct student stu4- ,void main() int i;float a,s; for(i=0;i4;i+) a=a+stui.age s=s+stui.score printf(4a/4 ,2. struct STU int num; float Total; ; void f(struct STU p) struct STU s2=20044,550,20045,537; p.num = s1.num; p.Total = s1.Total; void main() struct STU s2=20041,703,20042,580; f(s0); printf(%d %3.0fn, s0.num, s0.Total); _ A20045 537 B20044 550 C20042 580 D20041 703,D, ,9.3 struct *; struct student *p;, int n; int *p= ? n=10,struct student stu1; struct student *p= ? (*p).num=101,(*).,-,., : 1 򣺴,void main() struct student long int num; char name20; char sex; float score; stu,*p; p= , ,struct student int num; char name20; char sex; int age; stu3=10101,Li Lin,M,18, 10102,Zhang Fun,M,19, 10104,Wang Min,F,20; void main() struct student *p; for(p=stu; pnum, p-name, p-sex,p-age); ,p-n p-n+ +p-n,pn,pn, 1,pn1, ,1: struct ord int x,y; dt2=1,2,3,4; void main() struct ord *p=dt; printf(%d,+p-x); printf(%dn,+p-y); A)1,2 B)2,3 C)3,4 D)4,1,B,2. struct A int a; char b10;double c; void f(struct A *t); void main() struct A a=1001,ZhangDa,1098.0; f(,1. :stu1.numstu2.num,. 2. 3.飩飩,Nstu33,#include #define N 3 struct student int num; char name20; float score3; float aver; ;,void main() void input(struct student stu ); struct student max(struct student stu ); void print(struct student stu); struct student stuN,*p=stu; input(p); print(max(p); ,void input(struct student stu ) int i; for(i=0;iN;i+) scanf(%d %s %f %f %f, ,struct student max(struct student stu ) int i,m=0; for(i=0;istum.aver) m=i; return stu(m); void print(struct student stud) printf(%d,%s,%5.1f,%5.1f,%5.1f,:%6.2fn, stud.num,stud.name, stud.score0, stud.score1, stud.score2, stud.aver); , ,: , 塱.,干 union ,磺 union data union data int i int i; char ch char ch; float f float f a,b,c; ; union data a,b,c;,11-24, 1.泤泤 浥 2.泤 ,:涨塱 , ,:涨abc a.i 飩 a.ch裩 a.f 棩, 9.4 ,9.4.1 ,洢 ,11-10,彨 struct student int num float score struct student *next ; numscorenextstruct studentnext,11-11,9.4.2 ,#define NULL 0 struct student long num; float score; struct student *next; ;, 1010189.5 1010390.0 1010785.0,void main() struct student a,b,c,*head,*p; a. num=99101; a.score=89.5; b. num=99103; b.score=90; c. num=99107; c.score=85; head= ,9.4.3 2,#include #include #define LEN sizeof(struct student) struct student int num; float score; struct student *next; ;,void main() struct student *head,*p; head=p=(struct student*)malloc(LEN); scanf(%d,%f, , ,11-19, ,1壬 struct node int data; struct node *next; *p,*q,*r; data next data next data next p q r q_ Ap-next=q-next; Bp-next=p-next-next; Cp-next=r; Dp=q-next;,D,(),: typedef,typedef : typedef ;,INTEGER typedef int INTEGER typedef struct int month int day int yearDATE;, typedef (2) typedef (3) typedef #include (4) typedef, (5) typedef#define磺 typedef int COUNT#define COUNT int COUNTint #define򵥵 滻typedef 򵥵滻 ,1 typedef struct ST long a;int b;char c2;NEW; _ A BST CNEW DNEW,C,2td_ Atypedef struct aa Bstruct aa int n; int n; float m; float m; AA; td; AA td; struct aa td; Cstruct Dstruct int n; int n; float m; float m; aa; td; struct aa td;,C,3 Atypedef struct Bstruct REC; int n; char c;REC; int n; char c; REC t1,t2; REC t1,t2; Ctypedef struct REC ; int n=0; char c=A;t1,t2; Dstruct int n;char c;REC t1,t2;,(4) ,_ #include typedef struct int num;double s; REC; void fun1(REC x) x.num=23;x.s=88.5; main( ) REC a=16,90.0; fun1(a); printf(%dn,a.num); ,
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号