[说明] 假设设A和B均为顺序表,A’和B’分别为A和B中除去最大共同前缀后的子表(例如,A=(x,y,y,z,x,z),B=(x,y,y,z,y,x,x,z),则两者中最大的共同前缀为(x,y,y,z),在两表中除去最大共同前缀后的子表分别为A’=(x,z)和B’=(y,x,x,z)。若A’=B’=空表,则A=B;若A’=空表,而 B’!=空表,或者两者均不为空表,且A’的首先小于B’的首元,则A<B;否则A>B。 下面程序实现了比较A、B大小的算法。 [C程序] #include<stdio.h> #include<stdlib.h> typedef struct linknode { int data; struct linknode *next; }node: node *creatlist ( ) /*建立单链表*/{ node*head, *r, *s; int x; head= (node *) malloc (sizeof (node)); /建立单链表的头结点head*/ r=head; printf ("输入系列整数,以O标志结束\n"); scanf ("%d", &x); while (x!=O) /*x==O则退出while循环*/ { s=(node*) malloc (sizeof (node)); s->data=x; r->next=s; s->next=NULL; r=s; scanf ("%d", &x); } r->next=NULL; s=head; (1) ; Free (s); return head;}void subs ( ){ node*p, *p1, *p2, *q, *heada, *headb; heada=creatlist ( ) ; headb=creatlist ( ) ; p=heada; p1=p; /*p1指向p所指结点的前一个结点,开始时均缀向头结点*/ while (p!=NULL ) { q=headb; while (q!=NULL&&q->data!=p->data) q=q->next; if ( (2) ) { if (p==heada) { (3) ; p1=heada; } else if (p->next==NULL) p1->next=NULL; /*该结点为最后一结点,删除*/ else p1->next=p->next; p2=p->next; (4) ; free (p); (5) ; } else /*p所指结点的元素不在B中,则直接下移p*/ { p1=p; (6) ; }}p=heada; /*显示删除后的结果*/if (p==NULL) printf ("两集合机减的结果为空\n");else printf ("两集合相减的结果\n");while (p!=NULL){ printf ("%d", p->data); p=p->next;}}void main ( ){ subs ( ) ;}
1】 假设以带头结点的单循环链表作非递减有序线性表的存储结构。函数deleteklist(LinkList head)的功能是删除表中所有数值相同的多余元素,并释放结点空间。 例如:链表初始元素为: (7, 10,10,21,30,42,42,42,51,70) 经算法操作后变为: (7,10,21,30,42,51,70) 【函数3.1】 void deleteklist(LinkList head) LinkNode * p, * q; p=head->next; while(p!=head) q=p->next; while( (1) ) (2) ; free(q); q=p->next; p=p->next; 【说明3.2】 已知一棵完全二叉树存放于一个一维数组T[n]中,T[n]中存放的是各结点的值。下面的程序的功能是:从T[0]开始顺序读出各结点的值,建立该二叉树的二叉链表表示。 【函数3.2】 #include<istream.h> typedef struct node int data; stuct node leftChild, rightchild; BintreeNode; typedef BintreeNode * BinaryTree; void ConstrncTree(int T[], int n, int i, BintreeNode * &ptr) if(i>=n) (3) ; /*置根指针为空*/ else ptr=-(BTNode * )malloc(sizeof(BTNode) ) ptr->data=T[i]; ConstrucTree(T,n,2, i+1, (4) ); ConstrucTree(T,n, (5) ,ptr->rightchild); main(void) /*根据顺序存储结构建立二叉链表*/ Binarytree bitree;int n; printf("please enter the number of node: \n%s" ;n); int* A = (int *) malloc(n * sizeof(int)); for(int i=0;i<n;i++)scanf(" %d,A+i); /*从键盘输入结点值*/ for(int i=0;i<n;i++)printf(" %d",A[i]); ConstructTree(A, n,0, bitree);
There is nothing illogical or synthetic about the humility of great bookmen in calling attention to the lirnitations of the book.No book can (62) us to knOW everything that is to be known, or feel everything that is to be felt.A book is part of life, not a substitute (63) it.It is not a fit (64) for worship or enshrinement.It loses its charm and much of its value when accepted (65) .No one would have been more (66) than Aristotle if he could have known of the excessive and (67) veneration(尊敬, 崇拜)that would be given to his ideas in centuries to (68) . When his works became the (69) words of advance knowledge, (70) knowledge became neither advanced nor vital. The particular occasion for these remarks is that there are (71) here and there that some of US in the book would may be (72) ourselves too seriously.In the effort to increase book reading some (73) things are being said about books.It is made to (74) ,that nothing is happening now that has not happened before, and that the only tree approach to understanding is (75) books.We do neither service nor justice to books by (76) upon them such omnipotence(全能)and omniscience (全知).Many of the answers we need today are necessarily to be found between (77) .There are elements of newness in the present (78) of man that will not readily be (79) of by required reading or ready reference. Books are not slide rules or blueprints for (80) automatic answers.What is needed is a mighty blend of the wisdom of the ages (81) flesh, razor-edge analytical thought.
A. subject
B. issue
C. matter
D. image
依基金契约规定至计算日止对托管人或管理人应付未付报酬,是基金负债总额的一部分。( )
A. 对
B. 错