(37)有以下程序#include <stdio.h>struct ord{ int x,y;} dt[2]={1,2,3,4};main(){ struct ord *p=dt;printf (“%d,”,++p->x); printf(“%d\n”,++p->y);}程序的运行结果是A)1,2 B)2,3 C)3,4 D)4,1

题目

(37)有以下程序

#include <stdio.h>

struct ord

{ int x,y;} dt[2]={1,2,3,4};

main()

{ struct ord *p=dt;

printf (“%d,”,++p->x); printf(“%d\n”,++p->y);

}

程序的运行结果是

A)1,2 B)2,3 C)3,4 D)4,1


相似考题
更多“(37)有以下程序 #include &lt;stdio.h&gt; struct ord { int x,y;} dt[2]={1,2,3,4}; main() ”相关问题
  • 第1题:

    请选出以下程序的输出结果_______。 includesub(int*s,inty){ static int t=3,y=s[t];t

    请选出以下程序的输出结果_______。 #include<stdio.h> sub(int*s,inty) { static int t=3, y=s[t];t-; } main() { int a[]={1,2,3,4},i,x=0; for(i=0;i<4;i++){ sub(a,x);printf("%d",x);} printf("\n"); }

    A.1234

    B.4321

    C.0

    D.4444


    正确答案:C
    解析:x作为函数sub()的实参时,函数对x值的改变没有返回主函数,并不能使得x的值变化,所以在打印时,x的值是始终不变的,即为0。

  • 第2题:

    以下程序的输出结果是includestruct st{ int x;int *y;}*p;int dt[4]={10,20,30,40};s

    以下程序的输出结果是 #include<stdio.h> struct st { int x;int *y;}*p; int dt[4]={10,20,30,40}; struct st aa[4]={50,&dt[0],60,&dt[0],60,&dt[0],60,&dt[0],}; main() { p=aa; printf("%d\n",++(p->x));}

    A.10

    B.11

    C.51

    D.60


    正确答案:C
    解析:通过指针来引用结构体成员的方法是(指针变量)->结构体成员名。注意:结构体变量中的数据引用。

  • 第3题:

    (37)有以下程序

    #include <stdio.h>

    struct ord

    { int x,y;}dt[2]={1,2,3,4};

    main()

    {

    struct ord *p=dt;

    printf("%d,",++(p->x)); printf("%d\n",++(p->y));

    }

    程序运行后的输出结果是

    A)1,2

    B)4,1

    C)3,4

    D)2,3


    正确答案:D

  • 第4题:

    有以下程序: #include<stdio.h> struct ord {int X,y;)dt[2]={1,2,3,4}; main( ) { struct ord*p=dt; printf("%d,",++(p->x));printf("%d\n",++(p->y)); } 程序运行后的输出结果是( )。

    A.1,2

    B.4,1

    C.3,4

    D.2,3


    正确答案:D
    p一>x的值为1,++(p->x)作用是取p->x的值加1作为表达式的值即值为2,同理++(p->y)的值为3。所以选D。

  • 第5题:

    以下程序的输出结果是()。includestruct st{int x;int*y;}*p; int dt[4] ={ 10,20,30,4

    以下程序的输出结果是( )。 #include<stdio.h> struct st { int x; int *y;} *p; int dt[4] ={ 10,20,30,40 }; struct st aa[4]={ 50,&dt[0],60,&dt[0],60,&dt[0],60,&dt[0]}; main() { p=aa; printf("%d\n",++(p->x)); }

    A.10

    B.11

    C.51

    D.60


    正确答案:C
    解析:由于数组名保存了数组的首地址,即数组中第一个元素的地址,执行p=aa;后,p指向aa[0],p->x相当于aa[0].x,也就是50,经过自增运算后,显示结果为51。