有以下程序段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 结构变量

有以下程序段

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 结构变量


相关考题:

●试题三阅读下列函数说明和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;}}

阅读以下说明和c++代码,将应填入(n)处的字句写在对应栏内。【说明】本程序将两个从小到大的有序链表合成一个新的从小到大的有序链表。链表的每一项由类 Node描述,而链表由List描述,类List的成员函数有以下几个:creatList(): 创建从小到大的有序链表。multiplyList(List L1, Llst L2): 将链表L1和链表L2合并。print(): 打印链表。【C++代码】include <iostream>using namespace std;class List;class Node{friend class List;public:Node(int data){(1);}private:int data;Node *next;};class List{public:List(){list=NULL;}void multiplyList(List L1, List L2);void creatList();void print();private:Node *list;};void List::creatList(){Node *p, *u, *pre;int dara;list=NULL;wbile(1){cout<<"输入链表的一项: (小于零,结束链表) "<<endl;cin>>data;if(dara<0)break;//小于零,结束输入p=list;while(p !=NULL dara>p->data){//查找插入点pre=p;p=p->next;}u=(2);if(p==list)list=u;else pre->next=u;(3);}}void List::multiplyList(List L1, List L2){Node *pL1, *pL2, *pL, *u;list = NULL;pL1 = L1.list;pL2 = L2.11st;while(pL1 != NULL pL2 != NULL){if(pL1->data < pL2->data){u = new Node(pL1->data);pL1 = pL1->next;}else{u = new Node(pL2->data);pL2 = pL2->next;}if(list == NULL){list =(4);}else{pL->next=u;pL=u;}}pL1 = (pL1 != NULL)? pL1:pL2;while(pL1 != NULL){u=(5);pL1 = pL1->next;if(list == NULL){list=pL=u;}else{pL->next=u;pL=u;}}}void List::print(){Node *p;p = list;while(p !=NULL){cout<<p->data<<"\t";p=p->next;&

Simplify the following Boolean expression!((i ==12) || (j 15))struct Node {int value;Node* next;};1.1 Get the value of the Nth node from last node in the linked list.PARAM HEAD: the first element in the linked list:PARAM n: the number of the node counted reverselyRETURN: the value of the node, or -1 if not existsint GetValue(Node* HEAD, int n){}1.2 Delete a node WITHOUT using the HEAD pointer.PARAM p: A pointer pointed to a node in the middle of the linked list.RETURN: voidvoid Delete(Node* p){}1.3 Insert a new node before p WITHOUT using the HEAD pointerPARAM p: A pointer pointed to a node in the middle of the linked list.PARAM value: new Node valueRETURN: voidvoid Insert(Node* p, int value){}Question 2:Please write a String class with following features:

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

设链表中的结点是NODE类型的结构体变量,且有NODE*p;为了申请一个新结点,并由p指向该结点,可用以下语句()。Ap=(NODE*)malloc(sizeof(p));Bp=(*NODE)malloc(sizeof(NODE));Cp=(NODE)malloc(sizeof(p));Dp=(NODE*)malloc(sizeof(NODE));