有以下程序:
#include< stdio.h >
struct tt
{int x;struct tt*y;)*p;
struct tt a[4]={20,a+1,15,a+2,30,a+3,17,a};
main()
{int i;
p=a;
for(i=1;i< =2;i++){printf("%d,",p- >x);p=p- >y;}
}
程序的运行结果是( )。
【正确答案】
D
【答案解析】本题考查的是指针和结构的应用。首先定义的数组n中有两个成员,一个整型变量,一个结构指针。当i=1时,p指针指向结构数组的第一个元素,并输出此元素的第一个成员x,即20;当i=2时,p指针指向结构数组的第二个元素的第一个成员,所以输出15。