
十结构体与共同体(二) 一、填空题 1.以下程序的运行结果是 struct nf int x: char c: : nsin( struct n a=10,'x'】: fune (a): printf("sd,%"a.x.a.c) 1 func(struet n b) bx-20: b.c'y': 2.若有定义: structnum [int a: int b: floatf: 1e(1.35.0: struct mu pn=kn: 则表达式一b/L*+p一力的值是 一表达式(m).ap一>f的值是 3以下程序的运行结果是 struct ks [int a: int b:
十 结构体与共同体(二) 一、填空题 1.以下程序的运行结果是________. struct n{ int x; char c; }; main() {struct n a={10,'x'}; func(a); printf("%d,%c",a.x,a.c); } func(struct n b) { b.x=20; b.c='y'; } 2.若有定义: structnum {int a; int b; floatf; }n={1,3,5.0}; struct num *pn=&n; 则表达式 pn->b/n.a*++pn->b 的值是________,表达式(*pn).a+pn->f 的值是________. 3. 以下程序的运行结果是________. struct ks {int a; int *b;

}s4,和 min( { fmtn=1日 printf("\n") for(i=0:i4:i+) s[i].a-m: s[i】.b=4sf1】.a: n-+2: 1 =ks0】: : printf(d,dm°,(t+p)->a,pt+)->a); 1 4结构数组中存有三人的姓名和年龄,以下程序输出三人中最年长者的姓名 和年龄。请在 内填入正确内容。 stati struct nan( char name[20]: int age: ]person[]=("li=ming".18. “gang-hs”,l9 "zhang-ping”°,20 1: main( {struct man和,构i int old=0 p"persoa: for(:p_:p++) if (oldage)
}s[4],*p; main() { int n=1; printf("\n"); for(i=0;ia,(p++)->a); } 4.结构数组中存有三人的姓名和年龄,以下程序输出三人中最年长者的姓名 和年龄。请在_______内填入正确内容。 stati struct man{ char name[20]; int age; }person[]={"li=ming",18, "wang-hua",19, "zhang-ping",20 }; main() {struct man *p,*q; int old=0 p=person; for(;p_____;p++) if(oldage)

ap;:】 printf(sd”,): 反以下程序段的功能是饶计链表中结点的个数,其中fst为指向第一个结点 的指针(链表不带头结点)·睛在内填入正确内容。 struct link [char data struct link next; struct link和,*first: int c=0: p-first: hile(》 1
{q=p;______;} printf("%s %d",______); } 5. 以下程序段的功能是统计链表中结点的个数,其中 first 为指向第一个结点 的指针(链表不带头结点)。请在______内填入正确内容。 struct link {char data ; struct link *next; }; .... struct link *p,*first; int c=0; p=first; while(_____) {_______; p=_______; }