有以下程序:  #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-10-24  18

问题 有以下程序:
 #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的第1个元素,所以“p->x”为20。执行“p=p->y”后,p指向数组a的第2个元素,所以输出15。故本题答案为D选项。
转载请注明原文地址:https://jikaoti.com/ti/8ad0FFFM
0

相关试题推荐
随机试题
最新回复(0)