以下程序的输出结果是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

题目
以下程序的输出结果是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


相似考题
更多“以下程序的输出结果是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”相关问题
  • 第1题:

    下列程序的输出结果是()。 include VOid p(int *x) {printf("%d",++*x); } void main()

    下列程序的输出结果是( )。

    #include<stdio.h>

    VOid p(int *x)

    { printf("%d",++*x);

    }

    void main()

    { int y=3;

    p(&y);

    }

    A.3

    B.4

    C.2

    D.5


    正确答案:B
    解析:本题考查函数调用时的参数传递。在函数调用时,形参是指向实参的指针变量,则printf的执行结果为3+1=4。

  • 第2题:

    若有以下程序段:include using namespace std;int main (){ int a[]={1,4,5}; int *p

    若有以下程序段: #include <iostream> using namespace std; int main () { int a[]={1,4,5}; int *p=&a[0],x=6, y,z; for (y=0; y<3; y++) z= ( (* (p+y) <x) ? *(p+y) :x); cout<<z<<end1; return 0; } 程序运行后的输出结果是( )。

    A.1

    B.4

    C.5

    D.2


    正确答案:C
    解析:本题考核指针的运算。程序首先定义了一整型数组a,并赋初值1,4,5。即a[0],a[1]和a[2]的值分别为1,4和5。程序还定义了一个整型指针p,并将其初始化且指向数组元素a[0]。在for循环语句中,赋值语句“z=((*(p+y)x)?*(p+y):x);”可等价为“z=(a[y]x)?a[y]:x”。因为表达式中的“*(p+y)=p[y]=a[y]”。for语句每循环一次,就给变量z重新赋值一次,z的值其实就是数组和x相比较,将数组a中的最大值赋给z。当y=2后,退出循环,输出结果是5。

  • 第3题:

    以下程序的输出是( )。 struct st { int x;int *y; } *p; int dt[4]={10,20,30,40}; struct st aa[4]= {50,&dt[0],60,&dt[1],70,&dt[2],80,&dt[3]}; main() { p=aa; cout<<++p->x; cout<<(++p)->x; cout<<++(*p->y); }

    A.10 20 20

    B.50 60 21

    C.51 60 21

    D.60 70 31


    正确答案:C

  • 第4题:

    下列程序的输出结果是()。includemain(){struct st{int y,x,z;};union{long i; int j;

    下列程序的输出结果是( )。 #include<stdio.h> main() { struct st { int y,x,z; }; union { long i; int j; char k; }un; printf("%d,%d\n",sizeof(struct st),sizeof(un)); }

    A.6,2

    B.6,4

    C.8,4

    D.8,6


    正确答案:B
    解析: 本题主要考查结构体和联合内存使用的区别:结构中不同的成员分别使用不同的内存空间,一个结构所占内存空间的大小是结构中每个成员所占内存空间大小的总和,结构中每个成员相互独立;联合所占用的内存空间为最长的成员所占用的空间。

  • 第5题:

    以下程序的输出结果是( )。 {int x;int*y;}*p; int dt[4]={1,2,3,4}; struct st aa[4]={2,&dt[0],3,&dt[0],4,&dt[0],5,&dt[0],}; {p=aa; pfintf("%d\n",++(p->x)); }

    A.1

    B.2

    C.3

    D.4


    正确答案:C
    解析:程序首先将指针p指向结构体数组aa的首地址,通过p->x引用了结构体数组aa[0]的第一个成员2;++(p->x)是将p->x的值加1,所以输出结果为3。

  • 第6题:

    有以下程序:includestruct tt{int x;struct tt*y;}*p;struct tt a[4]={20,a+1,15,a+2,

    有以下程序: #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
    解析:本题考查的重点是对结构体的运用与理解。在a[4]的初始化中,相当于将其生成为一个链表,故打印两次相当于将前两个整数值打印出来.因此选项D是正确的。

  • 第7题:

    有以下程序 include struct st { int x,y;} data[2]={1,10,2,20}; main(

    有以下程序 #include <stdio.h> struct st { int x,y;} data[2]={1,10,2,20}; main() { struct st *p=data; printf("%d,",p->y); printf("%d\n",(++p)->x); } 程序的运行结果是______。

    A.10,1

    B.20,1

    C.10,2

    D.20,2


    正确答案:C
    解析:本题定义了一个包含两个元素(data[0]、data[1])的结构体数组data,其中data[0].x=1;data[0].y=10;data[1].x=2; data[1].y=20。在主函数中,定义了一个指向结构体数组的结构体指针变量p,使得p指向结构体数组的首地址,所以p->y访问的是第一个鲒构体数组元素的第二个值,即data[0].y;(++p)->x访问的是第二个结构体数组元素的第一个值,即 data[1].x,所以程序输出结果为10,2。

  • 第8题:

    以下程序输出结果是 ______。includevoid fun(int x,int y,int z){z=x+y;}void main

    以下程序输出结果是 ______。 #include<iostream.h> void fun(int x,int y,int z){z=x+y;} void main() { int a=10; fun (2,2,a); cout<<a; }

    A.0

    B.4

    C.10

    D.无定值


    正确答案:C

  • 第9题:

    以下程序执行后输出的结果是【】。 include using namespace std; int fac(int a,int b){

    以下程序执行后输出的结果是【 】。

    include<iostream>

    using namespace std;

    int fac(int a,int b){

    return(b-a)*a;

    }

    int main(){

    int x=3,y=4,z=5,result;

    result=fac(fac(x,y),fac(x,z));

    cout<<result<<endl;

    return 0;

    }


    正确答案:9
    9 解析:在main()函数中执行result=fac(fac(x,y),fac(x,2));调用了三次fac()函数: fac(x,y)的值为3,fac(x,z)的值为6,fac(3,6)得到的值为9。

  • 第10题:

    以下程序的输出是( )。 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; cout<+<+(p->x); }

    A.10

    B.11

    C.51

    D.60


    正确答案:C

  • 第11题:

    以下程序的输出结果是()。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。

  • 第12题:

    (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

  • 第13题:

    下列程序的输出结果是()。includevoidp(int*x){printf("%d",++*x);}voidmain(){int y=3

    下列程序的输出结果是( )。

    #include<stdio.h>

    voidp(int*x)

    {printf("%d",++*x);

    }

    voidmain()

    {int y=3;

    p(&y);

    }

    A.3

    B.4

    C.2

    D.5


    正确答案:B
    解析: 本题考查函数调用时的参数传递。在函数调用时,形参是指向实参的指针变量,则printf的执行结果为3+1=4。

  • 第14题:

    下列程序的输出结果是()。includevoid p(int *x){printf("%d",++*x);}void main(){int

    下列程序的输出结果是( )。 #include<stdio.h> void p(int *x) { printf("%d",++*x); } void main() { int y=3; p(&y); }

    A.3

    B.4

    C.2

    D.5


    正确答案:B
    解析:本题考查函数调用时的参数传递。在函数调用时,形参是指向实参的指针变量,则printf的执行结果为3+1=4。

  • 第15题:

    以下程序的输出是______。 struct st {int x;int*y; }*p; int dt[4]={10,20,30,40}; struct st aa[4]={50,&dt[0],60,&dt[1],60,&dt[2],60,&dt[3]}; main() { p=aa; printf("%d\n",++(p->X)); }

    A.51

    B.11

    C.50

    D.60


    正确答案:A
    解析:p是指向结构aa的结构指针,++(p->x)是对p的x成员的值进行加1。p=aa使得p指向aa的首地址,p->x的值为50,那么++(p->X)就等于51。

  • 第16题:

    有以下程序 include struct tt { int x; struct tt *y; } *p; s

    有以下程序 #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
    解析:题目中定义了一个全局结构体数组a,结构体中包含两个成员:一个int型变量x和一个自身类型指针y。所以,结构体数组a的初始化列表中每两个初始化一个结构体元素。主函数通过一个for循环,连续调用了两次输出函数printf(),每次输出p所指元素的x成员值。p初始化时指向数组 a的首地址,即a[0]的位置,所以第1次输出的值为20。然后又将a[0]的成员y的值赋给p,y在初始化时是a+1,所以p在第2次输出时指向的元素是a[1],故第2次输出的值为15。所以本题最终输出结果是“20,15,”,应该选择D。

  • 第17题:

    下列程序的输出结果是( )。 include main() { struct st { int y,x,z; }; union {long

    下列程序的输出结果是( )。 #include <stdio.h> main() { struct st { int y,x,z; }; union { long i; int j; char k; } un; printf("%d,%d\n",sizeof(struct st),sizeof(un)); }

    A.6, 2

    B.6, 4

    C.8, 4

    D.8, 6


    正确答案:B
    解析:本题主要考查结构体和联合内存使用的区别:结构中不同的成员分别使用不同的内存空间,一个结构所占内存空间的大小是结构中每个成员所占内存空间大小的总和,结构中每个成员相互独立;联合所占用的内存空间为最长的成员所占用的空间。

  • 第18题:

    有以下程序includestruct ord{ int x,y;} dt[2]={1,2,3,4};mare(){struct ord*p=dt; p

    有以下程序 #include<stdio.h> struct ord { int x,y;} dt[2]={1,2,3,4}; mare() { 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


    正确答案:B
    解析:本题主要考查了结构体变量成员的引用,有三种形式来引用结构体变量中的成员:(1)结构体变量名.成员名:(2)指针变量名->成员名;(3)(*指针变量名).成员名。其中点号“.”称为成员运算符;箭头“->”称为结构指向运算符。由于p->x指向了结构体的的成员x,而结构体中x的值为1,因此自增后变为2,p->y指向了结构体的成员y,而结构体中y的值为2,因此自增后变为3,因此,选项B是正确的。

  • 第19题:

    下列程序的输出结果是______。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,&dr[0],60,&dr[0],} main(){ p=aa; printf("%d\n",++(p->x));}

    A.51

    B.11

    C.10

    D.60


    正确答案:A

  • 第20题:

    有以下程序

    #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

  • 第21题:

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

  • 第22题:

    以下程序的输出结果是______。includestruct stu{int num; char name[10]; int age;};v

    以下程序的输出结果是______。#include<stdio.h>struct stu{ int num; char name[10]; int age;};void fun(struct stu*p){ printf("%s\n",(*p).name);}main(){ struct stu students[3]={ {9801,"Zhang",20}, { 9802,"Wang",19}, { 9803,"Zhao",18} }; fun(students+2);}

    A.Zhang

    B.Zhao

    C.Wang

    D.18


    正确答案:B

  • 第23题:

    以下程序的输出结果是 ( ) 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