单选题有以下程序#include 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; }}程序的运行结果是(  )。A20,15,B30,17,C15,30,D20,30,

单选题
有以下程序#include 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,15,

B

30,17,

C

15,30,

D

20,30,


参考解析

解析:
本题中结构体struct tt的成员包括它本身的指针struct tt*,定义了结构体数组a,并完成初始化,a[0].x=20,a[0].7=a+1,……,a[3].x=17,a[3].y=a。在主函数中,第一次for循环,i=1时:指针p指向数组a的首地址,即&a[0],因此p->x=a[0].x=20,p->y=a[0].y=a+1,则p=p->y就是将指针p后移一位指向a[1];i=2时,输出p->x等价于输出a[1].x,即15,之后再将p后移;当i=3时跳出循环。答案选择A选项。

相关考题:

有以下程序struct S {int n; int a[20];};void f(struct S *P){ int i,j,t;for(i=0;ip-n-1;i++)for(j=i+1;jp-n;j++)if(p-a[i]p-a[j]) { t=p-a[i]; p-a[i]=p-a[j]; p-a[j]=t; }}main( ){ int i; struct S s={10,{2,3,1,6,8,7,5,4,10,9}};f(s);for(i=0;is.n;i++) printf("%d",s.a[i]);}程序运行后的输出结果是A)1,2,3,4,5,6,7,8,9,10,B)10,9,8,7,6,5,4,3,2,1,C)2,3,1,6,8,7,5,4,10,9,D)10,9,8,7,6,1,2,3,4,5,

有以下程序#include stdio.hstruct 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,17C)15,30,D)20,15,

有以下程序#include stdio.hstruct 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,1B)20,1C)10,2D)20,2

有以下程序struct S {int n; int a[20];}; void f(struct S *P) {int i,j,t; for(i=0;in-1;i++) for(j=i+1;jn;j++) if(p-a[i]p-a[j]) { t=p-a[i]; p-a[i]=p-a[j]; p-a[j]=t; } } main() {int i; struct S s={10,{2,3,1,6,8,7,5,4,10,9}}; f(s); for(i=0;i printf(“%d”,s.a[i]); } 程序运行后的输出结果是( )。 A.1,2,3,4,5,6,7,8,9,10,B.10,9,8,7,6,5,4,3,2,1,C.2,3,1,6,8,7,5,4,10,9,D.10,9,8,7,6,1,2,3,4,5,

有以下程序#include stdio.hstruct 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,2B)2,3C)3,4D)4,1

下面程序的输出结果为( )。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],80dt[3]}; main() { p=aa; printf("%d\n",++p-x); printf("%d\n",(++p)-x); printf("%d\n",++(*p-y)); }A.10 B.50 C.51 D.60 20 60 60 70 20 21 21 31

(37)有以下程序#include stdio.hstruct 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

有以下程序 struct S{ int n;int a[20];}; voidf(struct S*p) { int i,j,t; for(i=0;i<p->n-1;i++) for(j=i+1;j<p->n;j++) if(p->a[i]>p->a[j]){t=p->a[i];p->a[i]=p->a[j];p->a[j]=t;} } main() { int i;struct S s={10,{2,3,l,6,8,7,5,4,10,9}}; f(s); for(i=0;i<s.n;i++)printf("%d,",s.a[i]); } 程序运行后的输出结果是A.1,2,3,4,5,6,7,8,9,10,B.10,9,8,7,6,5,4,3,2,1,C.2,3,1,6,8,7,5,4,10,9,D.10,9,8,7,6,1,2,3,4,5,

C数组名称是指针变量吗? 看这段程序,可是执行。#include stdio.hint main(int argc, char *argv[]){ struct info { char name[33]; int age; }; struct info aa[3]={"meng",20,"juan",29,"an",59}; struct info *p=aa; for(int i=0;i3;i++,p++) printf("%-6s %d\n",p-name,p-age);}将其改成这样:#include stdio.hint main(int argc, char *argv[]){ struct info { char name[33]; int age; }; struct info aa[3]={"meng",20,"juan",29,"an",59}; //struct info *p=aa; for(int i=0;i3;i++,aa++) printf("%-6s %d\n",aa-name,aa-age);}为什么就执行不了呢

以下程序运行后的输出结果【 】。struct NODE{int k;struct NODE *link;};main(){structNODEm[5],*p=m,*q=m+4;int i=0;while(p!=q){p->k=++i;p++;q->k=i++;q-;}q->k=i;for(i=0;i<5;i++)printf("%d",m[i].k);printf("\n");}

有以下程序 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,17C.15,30,D.20,15,

有以下程序: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,17C.15,30D.20,15

有以下程序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,2B.2,3C.3,4D.4,1

有以下程序 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,1B.20,1C.10,2D.20,2

有以下程序 #includestdio.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=l;i=2;i++){printf("%d,",p-x);P =p-y;} } 程序的运行结果是( )。A.20,30,B.30,17,C.15,30,D.20,15,

有以下程序#includestdio.hstruct 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=l;i=2;i++){printf(%d,,p-x);P =p-y;}}程序的运行结果是( )。A.20,30,B.30,17,C.15,30,D.20,15,

有以下程序:includestruct tt{ int x;struct tt *y;} *p;struct tt a[4]={20,a+1,15,a 有以下程序: #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,17C.15,30,D.20,15,

有以下程序#include stdio.hstruct st{ int x, y, z;} data[2]={3,10,2,20,15,7};main(){ struct st *p=data; printf("%d,", p-y); printf("%d\n",(++p)-x); }程序的运行结果是A.10,3 B.20,3 C.10,20 D.20,2

有以下程序: #includestdio.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,2B.4,1C.3,4D.2,3

有以下程序:struct S{int n;int a[20];};void f(struct S*P){int i,j,t;for(i=0;in-1;i++)fo 有以下程序: struct S{int n;int a[20];}; void f(struct S*P) { int i,j,t; for(i=0;i<P->n-1;i++) for(j=j+1;j<P->n-1;j++) if(p->a[i]>p->a[j]) {t=P->a[i];p->a[i]=P->a[j];p->a[j]=t} } main() {int i;struct S s{10,{2,3,1,6,8,7,5,4,10,9}}; f(&s); for(i=0;i<s.n;i++)printf("%d",s.a[i]);} 程序运行后的输出结果是( )。A.3B.4C.5D.6

有以下程序:include struct STU{char name[10]; int num; int Score;};main(){struct 有以下程序: #include <stdio.h> struct STU { char name[10]; int num; int Score; }; main() { struct STU s[5]={{"YangSan",20041,703},{"LiSiGuo",20042,580}, {"WangYin",20043,680},{"SunDan",20044,550}, {"Penghua",20045,537}}, *p[5],*t; int i,j; for(i=0;i<5;i++) p[i]=s[i]; for(i=0;i<4;i++) for(j=i+1;j<5;j++) if(p[i]->Score>p[j]->Score) { t=p[i];p[i]=p[j];p[j]=t;} printf("%d%d\n",s[1].Score,p[1]->Score); } 执行后的输出结果是( )。A.550 550B.680 680C.580 550D.580 680

有以下程序:includestxucttt{ intx;structtt *y;}*p;struct tta[4]={20,a+1,15,a+2,30 有以下程序: #include <stdio.h> stxuct 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,17C.15,30,D.20,15,

有以下程序#includestdio.hstruct 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,30B.30,17C.15,30D.20,15

(37)有以下程序#include stdio.hstruct 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,2B)4,1C)3,4D)2,3

单选题有以下程序:#include struct S{ int x,y;};main(){ struct S data[3] = {4,3,2,0,8,1}; int i; for(i=0;i3;i++)  printf(%d%d;,data[i].x, data[i].y1); printf();}程序运行后的输出结果是(  )。A41;20;80;B41;22;64;C40;21;80;D43;20;81;

单选题有以下程序:#include struct st{ int x,y;} data[2]={1,10,2,20};main(){ struct st *p=data; printf(%d,,p-y); printf(%d,(++p)-x);}程序运行的结果是(  )。A10,1B20,1C10,2D20,2

单选题有如下程序:#include struct S{ int x,y;};main(){ struct S data[2] = {4,3,1,9}; int i; for(i=0;i2;i++)  printf(%d,%d;,data[i].x, data[i].y1);}程序运行后的输出结果是(  )。A4,1;1,4;B4,1;2,4;C4,3;1,9;D4,3;2,3;