有以下程序:  #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;

admin2022-04-01  16

问题 有以下程序:
 #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:
    }
 }
 程序的运行结果是(          )。

选项 A、20,30,
B、30,17
C、15,30,
D、20,15,

答案D

解析 本题考查结构体变量的引用以及结构体数组。p指向a数组的第一个元素,所以p->x为20,然后p=p->y后,p指向数组a的第二个元素,所以输出15,选项D正确。
转载请注明原文地址:https://kaotiyun.com/show/r2kp777K
0

最新回复(0)