试题37有以下程序#include stdio.hmain(){ struct node {int n; struct node *next; }*p;struct node x[3]={{2,x+1},{4,x+2},{6,NULL}};p=x;printf(“%d,”, p?n);printf(“%d\n”, p?next?n);}程序运行后的输出结果是()A.2,3B.2,4C.3,4D.4,6

试题37

有以下程序

#include <stdio.h>

main()

{ struct node {int n; struct node *next; }*p;

struct node x[3]={{2,x+1},{4,x+2},{6,NULL}};

p=x;

printf(“%d,”, p?n);

printf(“%d\n”, p?next?n);

}

程序运行后的输出结果是()

A.2,3

B.2,4

C.3,4

D.4,6


相关考题:

有以下程序段typedef struct node { int data; struct node *next; } *NODE;NODE p;以下叙述正确的是A)p 是指向 struct node 结构变量的指针的指针B)NODE p ;语句出错C)p 是指向 struct node 结构变量的指针D)p 是 struct node 结构变量

函数 main() 的功能是 : 在带头结点的单链表中查找数据域中值最小的结点 . 请填空#include stdio.hstruct node{ int data;struct node *next;};int min(struct node *first)/* 指针 first 为链表头指针 */{ strct node *p; int m;p=first-next; m=p-data;p=p-next;for(;p!=NULL;p= _[20]_______ )if(p-datam) m=p-data;return m;}

有以下程序段 typedef struct node { int data; struct node *next; } *NODE; NODE p; 以下叙述正确的是( )。A.p是指向struct node结构变量的指针的指针B.NODE p;语句出错C.p是指向struct node结构变量的指针D.p是struct node结构变量

以下程序的功能是:建立一个带布头结点的单向链表,并将存储在数组中的字符依次存储到链表的各个结点中,请从与下划线处号码对应的一组选项中选择出正确的选项#include <stdlib.h>struct node{char data; struct node *next;};(48) CreatList(char*s),{struct node *h,*p,*q;h=(struct node*)malloc(sizeof(struct node));p=q=h;while(*s!="\0"){ p=(struct node*)malloc(sizeof(struct node));p->data= (49) ;q->next=p;q= (50) ;s++;}p->next="\0";return h;}main(){ char str[]="link list";struct node*head;head=CreatList(str);…}(1)A.char*B.struct nodeC.struct node*D.char

有以下程序#includestruct 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\n ",p-num+q-next-num);}程序运行后的输出结果是A.10B.20C.30D.40

函数min()的功能是:在带头结点的单链表中查找数据域中值最小的结点。请填空includestruc 函数min()的功能是:在带头结点的单链表中查找数据域中值最小的结点。请填空include <stdio.h>struct node{ int data;struct node *next;};int min(struct node *first)/*指针first为链表头指针*/{ struct node *p; int m;p=first->next; re=p->data; p=p->next;for( ;p!=NULL;p=【 】)if(p->data<m ) re=p->data;return m;}

有以下程序: inClude structNODE{ int num; structNODE*next; }; main() {StructN00E 有以下程序:#inClude <stdlib.h>struct NODE{int num;struct NODE *next;};main(){ Struct N00E *p,*q,*r;int sum;0;p=(struct NODE *)malloc(sizeof(struct NODE));q=(struct NODE *)malloc(sizeof(struct NODE));r=(struct NODE *)malloc(Sizeof(struct NODE));p->num=1;q->num=2;r->num=3;p->next=q;q->next=r;r->next=NULL;sum+=q->next->num;sum+=p->num;printf("%d\n",sum);}执行后的输出结果是A.3B.4C.5D.6

有以下程序: include include struct NODE {int num;struct NODE *next; } 有以下程序:#include <stdio.h>#include <stdlib.h>struct NODE{ int num;struct NODE *next;};main(){ struet NODE *p,*q,*r;int sum=0;p=(struct NODE *) malloc(sizeof(struct NODE));q=(struct NODE *) malloc(sizeof(struet NODE));r=(struct NODE *) malloc(sizeof(struct NODE));P- >num=1;q- >num=2;r->num=3;p- >next=q;q- >next=r;r- >next=NULL;sum + =q- >next- >num;sum + =P- >num;printf("%d\n",sum);}执行后的输出结果是( )A.3B.4C.5D.6

以下程序运行后的输出结果是【 】。struct NODE{int num;struct NODE *next;};main(){struct NODE s[3]={{1,'\0'},{2,'\0'},{3,'0'}},*p,*q,*r;int sum=0;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\n",sum);}

以下程序把三个NODEIYPE型的变量链接成—个简单的链表,并在while循环中输出链表结点数据域中的数据。请填空。include<stdio.h>struct node{ int data;struct node*next;);typedef struct node NODETYPE;main(){ NODETYPEa,b,c,*h,*p;a.data=10;b.data=20;c.data=30;h=a;anext=b;b.next=c;c,next='\0';p=h;while(p){printf("%d,",p->data):【 】;}printf("\n");}

以下程序的功能是:建立一个带有头结点的单向链表,并将存储在数组中的字符依次转储到链表的各个结点中,请从与下划线处号码对应的一组选若中选择出正确的选项。#include stuct node{ char data; struct node *next;}; (48) CreatLis(char *s){ struct node *h,*p,*q); h=(struct node *)malloc(sizeof(struct node)); p=q=h; while(*s!='\0') { p=(struct node *)malloc(sizeof(struct node)); p-data= (49) ; q-next=p; q= (50) ; s++; } p-next='\0'; return h;}main(){ char str[]="link list"; struct node *head; head=CreatLis(str); ...}A.char *B.struct nodeC.struct node*D.char

有以下程序: #include stdio.h main( ) { struct node{int n; struct node*next;} *P; struct node x[3]={{2,x+1),{4,x+2},{6,NULL}}; P= X; printf("%d,",p-n); printf("%d\n",p-next-n); } 程序运行后的输出结果是( )。A.2,3B.2,4C.3,4D.4, 6

有以下程序 include struct NODE {int num;stmct NODE*next;}; main() { struct NODE 有以下程序#include<stdlib.h>struct NODE{ int num;stmct 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\n”,p->num+q->next->num);}程序运行后的输出结果是A.10B.20C.30D.40

有以下程序: include struct NODE{ int num; struct NODE*next; } main() {structNOD 有以下程序:#include<stdlib.h>struct NODE{int num;struct NODE *next;}main(){ struct NODE *p,*q,*r;int sum=0;p=(struct NODE *)malloc(sizeof(struct NODE));q=(Struct NODE *)malloc(sizeof(struct NODE));r=(Struct NODE *)malloc(sizeof(struct NODE));p->num=1; q->num=2; r->num=3;p->next=q; q->next=r; r->next=NULL;sum+=q->next->num;sum+=p->num;printf("%d\n",sum);}执行后的输出结果是( )。A.3B.4C.5D.6

有以下程序 include struct NODE{ int num; struct NODE *next;}; main( ) 有以下程序#include <stdlib.h>struct NODE{int num;struct NODE *next;};main( ){ struct NODE *p,*q,*r;int sum=0;p=(struct NODE *)malloc(sizeof(struct NODE));q=(struct NODE *)malloc(sizeof(struct NODE));r=(struct NODE *)malloc(sizeof(struct NODE));p->num=1;q->num=2;r->num=3;p->next=q;q->next=r;r->next=NULL;sum+=q->next->num;sum+=p->num;printf(“%d\n”,sum);}执行后的输出结果是A.3B.4C.5D.6

下列给定程序中,是建立一个带头结点的单向链表,并用随机函数为各结点数据域赋值。函数fun的作用是求出单向链表结点(不包括头结点)数据域中的最大值,并且作为函数值返回。请改正程序指定部位的错误,使它能得到正确结果。[注意] 不要改动main函数,不得增行或删行,也不得更改程序的结构。[试题源程序]include<stdio.h>include<stdlib.h>typedef struct aa{int data;struct aa *next;}NODE;fun(NODE *h){int max=-1;NODE *p;/***********found************/p=h;while(p){if(p->data>max)max=p->data;/************found************/p=h->next;}return max;}outresult(int s, FILE *Pf){fprintf(pf, "\nThe max in link: %d\n", s);}NODE *creatlink(int n, int m){NODE *h, *p, *s, *q;int i, x;h=p=(NODE *)malloc(sizeof(NODE));h->data=9999;for(i=1; i<=n; i++){s=(NODE *)malloc(sizeof(NODE));s->data=rand()%m; s->next=p->next;p->next=s; p=p->next;}p->next=NULL;return h;}outlink(NODE *h, FILE *pf){NODE *p;p=h->next;fprintf(Pf, "\nTHE LIST:\n\n HEAD");while(P){fprintf(pf, "->%d", P->datA); p=p->next;}fprintf(pf, "\n");}main(){NODE *head; int m;head=cteatlink(12,100);outlink(head, stdout);m=fun(head);printf("\nTHE RESULT"\n");outresult(m, stdout);}

有以下程序: include struct NODE { int num; struct NODE*next; }; main() { struct 有以下程序:#include <stdlib.h>struct NODE{ int num; struct NODE *next; };main(){ struct NODE *p,*q,*r;p=(struct NODE*)malloc(sizeof(struct NODE));q=(struct NODE*)mallloc(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\n",p->num+q->next->num);}程序运行后的输出结果是( )。A.10B.20C.30D.40

有以下程序 include gtruet NODE {intnum;struct NODE *next;}; main() {struct NODE 有以下程序#include <stdlib.h>gtruet 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(sizeef (struct NODE));p->num=10; q->num=20; r->num=30;p->next=q; q->next-r;printf("%d\n",p->num+q->next->num);}程序运行后的输出结果是A.10B.20C.30D.50

有以下程序#ncludestdio.hmain(){ struct node{int n;struct nodc*next;}*p;struct node x[3]={{2,x+1},{4,x+2},{6,NULL}};p=x:printf("%d,",p-n);printf("%d\n",P-next-n);}程序运行后的输出结果是A.2,3B.2,4C.3,4D.4,6

有以下程序: include struct NODE {int num;stmct NODE *next;}; main( ) { str 有以下程序:#include<stdlib.h>struct NODE{ int num;stmct 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\n",p->num+q->next->num);}程序运行后的输出结果是A.10B.20C.30D.40

有以下程序 include struct NODE {int num;struct NODE*next;} main() {struct NODE 有以下程序#include<stdlib.h>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(struet 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\n",p->num+q->next->num):}程序运行后的输出结果是( )A.10B.20C.30D.40

以下程序的功能是:建立一个带有头结点的单向链表,并将存储在数组中的字符依次转存到链表的各个结点中,请填空。 #include <stdlib.h> stuct node { char data; struet node * next; }; stntct node * CreatList(char * s) { struet node *h,*p,*q; h = (struct node * ) malloc(sizeof(struct node) ); p=q=h; while( * s! ='\0') { p = (struct node *) malloc ( sizeof(struct node) ); p - > data = ( ) q- >next=p; q=p; a++; p- > next ='\0'; return h; } main( ) { char str[ ]= "link list"; struet node * head; head = CreatList(str);A.*sB.sC.*s++D.(*s)++

有以下程序 inGlude struct NODE { int num; struct NODE *next; } main() {struct N 有以下程序#inGlude<stdlib.h>struct NODE {int num;struct NODE *next;}main(){ struct NODE *p,*q,*r;int sum=0;p=(struct NODE*)malloc(sizeof(struct NODE));q=(struct NODE*)malloc(sizeof(struct NODE));r=(stnlct NODE*)malloc(sizeof(struct NODE));p->num=1;q->num=2;r->num=3;p->next=q;q->next;r;r->next=NULL;sum+=q->next->Num,sum+=p->num;printf("%d\n",sum);}执行后输出结果是A.3B.4C.5D.6

有以下程序: include struct NODE{int nurn;struct NODE *next; }; main() { struct 有以下程序:#include <stdlib.h>struct NODE{int nurn;struct NODE *next;};main(){ struct NODE *p,*q,*r;int sum=0;P=(struct NODE*)malloc(sizeof(struct NODE));q=(struct NODE*)malloc(sizeof(struct NODE));r=(struct NODE*)malloc(sizeof(struct NODE));p->num=1;q->num=2;r->num=3;p->next=q;q->next=r;r->next=NULL;sum+=q->next->num;sum+=p->num;Printf("%d\n",sum);}执行后的输出结果是( )。A.3B.4C.5D.6

下面程序的功能是建立一个有 3 个 结 点的单向循环链表,然后求各个 结 点数值域 data 中数据的和。请填空。include stdio.hinclude stdlib.hstruct NODE{ int data;struct NODE *next;};main(){ struct NODE *p,*q,*r;int sum=0;p=(struct NODE*)malloc(sizeof(struct NODE));q=(struct NODE*)malloc(sizeof(struct NODE));r=(struct NODE*)malloc(sizeof(struct NODE));p-data=100; q-data=200; r-data=200;p- next =q; q- next =r; r- next =p;sum=p-data+p-next-data+r-next-next 【 19 】 ;printf("%d\n",sum);}

问答题下列给定程序是建立一个带头结点的单向链表,并用随机函数为各结点赋值。函数fun()的功能是:将单向链表结点(不包括头结点)数据域为偶数的值累加起来,并作为函数值返回。  请改正函数fun中的错误,使它能得出正确的结果。  注意:部分源程序在文件MODII.C中,不要改动main函数,不得增行或删行,也不得更改程序的结构!  试题程序:#include #include #include typedef struct aa{ int data; struct aa *next;}NODE;int fun(NODE *h){ int sum=0; NODE *p; p=h-next; /*********found*********/ while(p-next) {  if(p-data%2==0)   sum+=p-data;  /*********found*********/  p=h-next; } return sum;}NODE *creatlink(int n){ NODE *h,*p,*s; int i; h=p=(NODE *)malloc(sizeof(NODE)); for(i=1;idata=rand()%16;  s-next=p-next;  p-next=s;  p=p-next; } p-next=NULL; return h;}outlink(NODE *h){ NODE *p; p=h-next; printf("The LIST: HEAD"); while(p) {  printf("-%d",p-data);  p=p-next; } printf("");}main(){ NODE *head; int sum; system("CLS"); head=creatlink(10); outlink(head); sum=fun(head); printf("SUM=%d",sum);}

单选题有以下程序:#include main(){ struct node {  int n;  struct node *next; } *p; struct node x[3] = {{2,x+1},{4,x+2},{6,NULL}}; p=x; printf(%d,,p-n); printf(%d,p-next-n);}程序运行后的输出结果是(  )。A2,3B2,4C3,4D4,6