运行下列程序段,输出结果是( ) 。 struct country { int num; char name[10]; }x[5]={1,"China",2,"USA",3,"France",4, "England",5, "Spanish"}; struct country *p; p=x+2; printf("%d,%c",p->num,(*p).name[2]);
举一反三
- 中国大学MOOC:2.运行下列程序,输出结果是【】structcontry{intnum;charname[20];}x[5]={1,China,2,USA,3,France,4,Englan,5,Spanish};main(){inti;for(i=3;i<5;i++)printf(%d%c,x[i].num,x[i].name[0]);}
- 以下程序输出结果是____。struct student{short int x ; short int *y;} *p ;short int dt[4]={ 10 , 20 , 30 , 40 };struct student a[4]={50,&dt[0],60,&dt[1],70 ,&dt[2],80,&dt[3]} ;...p=a;printf("%d ",++p->x); printf("%d ",(++p)->x); printf("%d\n",++(*p->y)); }
- 以下程序运行后的输出结果是 ________ struct NODE { int num; struct NODE *next; } main() { struct NODE s[3], *p, *q, *r; int sum=0; s[0].num=1; s[1].num=2; s[2].num=3; s[0].next=s+1; s[1].next=s+2; s[2].next=s; p=s; q=p->next; r=q->next; sum+=q->next->num; sum+=r->next->next->num; printf("%d", sum); }
- 分析程序,写出运行结果 #include "stdio.h" main() {struct num {int x;int y;}sa[]={{2,32},{8,16},{4,48}}; struct num *p=sa+1; int x; x=p->y/sa[0].x*++p->x; printf("x=%d p->x=%d",x,p->x); }
- 有以下程序 #include struct NODE {int num; struct NODE *next; } main() {struct NODE *p,*q,*r; p=(struct NODE *)malloc(sizeof(struct NODE)); q=(struct NODE *)malloc(sizeof(struct NODE)); r=(struct NODE *)malloc(sizeof(struct NODE)); p->num=10;q->num=20;r->num=30; p->next=q;q->next=r; printf("%d ",p->num+q->next->num); } 程序运行后的输出结果是( )