网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
有以下程序 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.10

B.20

C.30

D.50


参考答案

更多 “ 有以下程序 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 ” 相关考题
考题 ●试题三阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】函数diff的功能是:根据两个由整数(都大于-32768)按升序构成的单链表L1和L2(分别由A,B指向)构造一个单链表L3(由*r指向),要求L3中的所有整数都是L1,并且不是L2中的整数,还要求L3中的所有整数都两两不等。【函数】#include<malloC.htypedef struct node{int d;struct node *next}Node;void diff(Node *A,Node *B,Node **r){int lastnum;Node*p;*r=NULL;if(!A)return;while( (1) )if(A-dB-d){lastnum=A-d;p=(Node*)malloc(sizeof(Node));p-d=lastnum;p-next=*r; (2) ;doA=A-next;while( (3) );}else if(A-dB-d)B=B-next;else{(4) ;lastnum=A-d;while (A A-d==lastnum)A=A-next;}while(A){lastnum=A-d;p=(Node*)malloc(sizeof(Node));p-d=lastnum;(5) ;*r=p;while (A A-d==lastnum) A=A-next;}}

考题 阅读下列函数说明和C代码,将应填入(n)处的字句写在对应栏内。【说明】函数diff的功能是:根据两个由整数(都大于-32768)按升序构成的单链表L1和L2(分别由A,B指向)构造一个单链表L3(由*r指向),要求13中的所有整数都是L1,并且不是 L2中的整数,还要求L3中的所有整数都两两不等。【函数】include < malloc. h >typedef struct node {int d;struct node * next} Node;void diff(Node *A,Node * B,Node * * r){int lastnum;Node * p;*r = NULL;if( ! A) return;while((1))if(A->d < B ->d){lastnum =A -> d;p= ( Node * ) malloc( sizeof(Node) );p->d = lastnum;p->next= *r;(2);doA = A -> next;while((3));}else if(A->d > B->d)B=B- >next;else {(4);lastnum=A -> d;while ( A A->d = = lastnum) A=A-> next;}while(A){lastnum=A->d;p=( Node * ) malloc( sizeof(Node) );p-> d = lastnum;(5);*r=p;while (A A->d = = lastnum) A=A->next;}}

考题 请补充函数fun(),该函数的功能是建立一个带头结点的单向链表并输出到文件“out98.dat”和屏幕上,各结点的值为对应的下标,链表的结点数及输出的文件名作为参数传入。注意:部分源程序给出如下。请勿改动主函数main 和其他函数中的任何内容,仪在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<stdio. h>include<conio. h>include<stdlib. h>typedef struct ss{int data;struct ss *next;} NODE;void fun(int n,char*filename){NODE *h,*p, *s;FILE *pf;int i;h=p= (NODE *) malloc (sizeof (NODE));h->data=0;for (i=1; i {s=(NODE *)malloc (sizeof (NODE));s->data=【 】;【 】;p=【 】}p->next=NULL;if ( (pf=fopen (filename, "w") ) ==NULL){printf {"Can not open out9B.clat! ");exit (0);}p=h;fprintf (pf, "\n***THE LIST***\n");print f ("\n***THE LIST***\n")while (p){fprintf (pf, "%3d", p->data)printf ("%3d",p->data);if (p->next ! =NULL){fprintf (pf, "->");printf ("->");}p=p->next;}fprintf (pf, "\n");printf ("\n");fclose (pf);p=h;while (p){s=p;p=p->next;free (s);}}main(){char * filename="out98. dat";int n;clrscr ();printf (" \nInput n: ");scanf ("%d", n);fun (n, filename);}

考题 阅读下列程序说明和C程序,已知其输出为“1 2 3 4 5 6 7 8 9 10”。将应填入(n)处的字句写在对应栏内。[说明]本程序包含的函数及其功能说明如下:(1)函数first_insert()的功能是在已知链表的首表元之前插入一个指定值的表元;(2)函数reverse_copy()的功能是按已知链表复制出一个新链表,但新链表的表元链接顺序与已知链表的表元链接顺序相反;(3)函数Print_link()用来输出链表中各表元的值;(4)函数free_link()用来释放链表全部表元空间。[程序]include <stdio. h >include <malloe. h >typodef struct node {int val;struct node * next;} NODE;void first_insert(NODE * * p,int v){ NODE *q = (NODE *) malloe(sizeof(NODE));q-val = v; q->next = *p; /* 为新表元赋值*/* p =(1); }NODE * reverse_copy( NODE * p){ NODE * u;for(u=NULL; p!=NULL; p=p->next) first_insert((2));return u;}void printlink(NODE * p ){ for(;(3)) prinff("%d\t", p-val);printf(" \n");}void free_link( NODE * p){ NODE * u;while(p! =NULL) { u=p-next;free(p);(4); }void main( ) { NODE * link1 , * link2;int i;link1 = NULL;for(i=1; i<= 10; i+ + )first_insert(linkl, i);link2 = reverse_copy(link1 );(5);free_link( linkl ) ;free_link(link2); }

考题 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。[说明]下面程序实现十进制向其它进制的转换。[C++程序]include"ioStream.h"include"math.h"includetypedef struct node {int data;node*next;}Node;Class Transform.{DUDlic:void Trans(int d,int i); //d为数字;i为进制void print();private:Node*top;};void Transform.:Trans(int d,int i){int m,n=0;Node*P;while(d>0){(1);d=d/i;p=new Node;if(!n){p->data=m;(2);(3);n++;}else{p->data=m;(4);(5);}}}void Transform.:print(){Node*P;while(top!=NULL){p=top;if(p->data>9)cout<<data+55;elsecout<<data;top=p->next;delete p;}}

考题 已知形成链表的存储结构如下图所示,则下述类型描述中的空白处应填______。 struct 1ink { char data; }node;A.struct link nextB.link*nextC.sluct next linkD.struct link*next

考题 下列给定程序中,是建立一个带头结点的单向链表,并用随机函数为各结点数据域赋值。函数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);}

考题 下而程序实现十进制向其他进制的转换。[C++程序]include"ioStream.h"include"math.h"include <conio.h>typedef struct node{int data;node *next;}Node;class Transform{public:void Trans(int d,int i); //d为数字;i为进制void print();private:Node *top;};void Transform.:Trans(int d,int i){int m,n=0;Node *P;while(d>0){(1) ;d=d/i;p=new Node;if(!n){P->data=m;(2) j(3) ;n++;}else{p->data=m;(4) ;(5) ;}}}void Transform.:print(){Node *P;while(top!=NULL){p=top;if(P->data>9)cout<<data+55:elsecout<<data;top=p->next;delete P;}}

考题 有以下程序: 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

考题 以下程序中函数fun的功能是:构成—个如图所示的带头结点的单向链表,在结点的数据域中放入了具有两个字符的字符串。函数disp的功能是显示输出该单向链表中所有结点中的字符串。请填空完成函数disp。include<stdio.h>typedef struct node /*链表结点结构*/{ char sub[3];struct node *next;}Node;Node fun(char s) /* 建立链表*/{ ...... }void disp(Node *h){ Node *p;p=h->next;while([ ]){printf("%s\n",p->sub);p=[ ];}}main(){ Node *hd;hd=fun(); disp(hd);printf("\n");}