网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
int AA(LNode *HL , ElemType x)
{
int n=0; LNode *p=HL;
while (p!=NULL)
{
if (p->data= =x) n++;
p=p->next; }
return n;
}
对于结点类型为LNode的单链表,以上算法的功能为:()
参考答案
更多 “ int AA(LNode *HL , ElemType x){int n=0; LNode *p=HL;while (p!=NULL){if (p->data= =x) n++;p=p->next; }return n;}对于结点类型为LNode的单链表,以上算法的功能为:() ” 相关考题
考题
下面程序实现十进制向其他进制的转换。[Java程序]C1ass Node{int data;Node next;}class Transform{private Node top;publiC void print(){Node P;while(top !=null){P=top;if(P.data>9)System.out.print((char)(p.data+55));elseSystem.out.print(p.data);top=P.next;}}public void Trans(int d,int i)(//d为数字;i为进制int m;(1) n=false;Node P;while(d>0){(2) ;d=d/i;P=flew Node();if( (3) ){P.data=m;(4) ;top=P;n=true;}else{p.data=m;(5) ;toP=P;}}}}
考题
以下程序的输出结果是#includestdio.hstruct st{ int x;int *y;}*p;int dt[4]={10,20,30,40};struct st aa[4]={50,dt[0],60,dt[0],60,dt[0],60,dt[0],};main(){ p=aa;printf("%d\n",++(p-x));}A.10B.11C.51D.60
考题
请补充函数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++程序,将应填入(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 st { int x;int *y; } *p; int dt[4]={10,20,30,40}; struct st aa[4]= {50,dt[0],60,dt[1],70,dt[2],80,dt[3]}; main() { p=aa; cout<<++p->x; cout<<(++p)->x; cout<<++(*p->y); }A.10 20 20B.50 60 21C.51 60 21D.60 70 31
考题
函数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;}
考题
以下程序的输出是______。 struct st {int x;int*y; }*p; int dt[4]={10,20,30,40}; struct st aa[4]={50,dt[0],60,dt[1],60,dt[2],60,dt[3]}; main() { p=aa; printf("%d\n",++(p->X)); }A.51B.11C.50D.60
考题
以下程序的输出结果是( )。 {int x;int*y;}*p; int dt[4]={1,2,3,4}; struct st aa[4]={2,dt[0],3,dt[0],4,dt[0],5,dt[0],}; {p=aa; pfintf("%d\n",++(p->x)); }A.1B.2C.3D.4
考题
阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内。[说明]下面程序实现十进制向其它进制的转换。[Java程序]ClasS Node{int data;Node next;}class Transform{private Node top;public void print(){Node p;while(top!=null){P=top;if(P.data>9)System.out.print((char)(P.data+55));elseSystem.out.print(p.data);top=p.next;}}public void Trans(int d,int i){//d为数字;i为进制int m;(1) n=false;Node p;while(d>0){(2);d=d/i;p=new Node();if( (3) ){p.data=m;(4);top=P;n=true;}else{p.data=m;(5);top=P;}}}}
考题
下列程序的输出结果是______。struct st{ int x;int*y;}*p; int dt[4]={ 10,20,30,40 }; struct st aa[4]={50,dt[0],60,dt[0],60,dr[0],60,dr[0],} main(){ p=aa; printf("%d\n",++(p->x));}A.51B.11C.10D.60
考题
下面程序的输出结果为( )。 struct st {int x;int *y;}*p; int dt[4]={10,20,30,40); struct st aa[4]={50,dt[0],60,dt[1],70,dt[2],80,dt[3]}; main() { p=aa; printf("%d\n",++p->x); printf("%d|n",(++p)->x); printf("%d\n",++(*p->y)); }A.10 20 20B.50 60 21C.51 60 21D.60 70 31
考题
执行下列语句后指针及链表的示意图为(43)。L = (LinkList) malloc ( sizeof (LNode) );P = L;for(i =0;i <=3;i ++) {P→next = (LinkList) malloc (sizeof (LNode));P = P→next;P→data = i * i + 1;}A.B.C.D.
考题
阅读下列函数说明和C函数,将应填入(n)处的字句写在对应栏内。[说明]二叉树的二叉链表存储结构描述如下:lypedef struct BiTNode{ datatype data;street BiTNode *lchiht, *rchild; /*左右孩子指针*/ } BiTNode, *BiTree;下列函数基于上述存储结构,实现了二叉树的几项基本操作:(1) BiTree Creale(elemtype x, BiTree lbt, BiTree rbt):建立并返回生成一棵以x为根结点的数据域值,以lbt和rbt为左右子树的二叉树;(2) BiTree InsertL(BiTree bt, elemtype x, BiTree parent):在二叉树bt中结点parent的左子树插入结点数据元素x;(3) BiTree DeleteL(BiTree bt, BiTree parent):在二叉树bt中删除结点parent的左子树,删除成功时返回根结点指针,否则返回空指针;(4) frceAll(BiTree p):释放二叉树全体结点空间。[函数]BiTree Create(elemtype x, BiTree lbt, BiTree rbt) { BiTree p;if ((p = (BiTNode *)malloc(sizeof(BiTNode)))= =NULL) return NULL;p->data=x;p->lchild=lbt;p->rchild=rbt;(1);}BiTree InsertL(BiTree bt, elemtype x,BiTree parent){ BiTree p;if (parent= =NULL) return NULL;if ((p=(BiTNode *)malloc(sizeof(BiTNode)))= =NULL) return NULL;p->data=x;p->lchild= (2);p->rchild= (2);if(parent->lchild= =NULL) (3);else{p->lchild=(4);parent->lchild=p;}return bt;}BiTree DeleteL(BiTree bt, BiTree parent){ BiTree p;if (parent= =NULL||parent->lchild= =NULL) return NULL;p= parent->lchild;parent->lchild=NULL;freeAll((5));return bt;
考题
下列给定程序中,是建立一个带头结点的单向链表,并用随机函数为各结点数据域赋值。函数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;}}
考题
有以下程序:struct S{int n;int a[20];};void f(struct S*P){int i,j,t;for(i=0;in-1;i++)fo
有以下程序: struct S{int n;int a[20];}; void f(struct S*P) { int i,j,t; for(i=0;i<P->n-1;i++) for(j=j+1;j<P->n-1;j++) if(p->a[i]>p->a[j]) {t=P->a[i];p->a[i]=P->a[j];p->a[j]=t} } main() {int i;struct S s{10,{2,3,1,6,8,7,5,4,10,9}}; f(&s); for(i=0;i<s.n;i++)printf("%d",s.a[i]);} 程序运行后的输出结果是( )。A.3B.4C.5D.6
考题
以下程序的输出是( )。 struct st { int x;int *y; } *p; int dt[4]={10,20,30,40}; struct st aa[4]={50,dt[0],60,dt[0],60,dt[0],60,dt[0],}; main() { p=aa; cout<+<+(p->x); }A.10B.11C.51D.60
考题
以下程序的输出结果是includestruct st{ int x;int *y;}*p;int dt[4]={10,20,30,40};s
以下程序的输出结果是 #include<stdio.h> struct st { int x;int *y;}*p; int dt[4]={10,20,30,40}; struct st aa[4]={50,dt[0],60,dt[0],60,dt[0],60,dt[0],}; main() { p=aa; printf("%d\n",++(p->x));}A.10B.11C.51D.60
考题
下列程序的输出结果是______。 union un { int a[3]; long b; char c[6]; }un1,*p; main() {p=un1; p->a[0]=0x37; p->a[1]=0x38; p->a[2]=0x39; printf("%c\n",p->c[4]); }A.39B.9C.38D.8
考题
以下C语言程序的输出结果是( )。struct s{int x,y;}data[2]={10,100,20,200};main( ){struct s*p=data;p++;printf(“%d\n”,++(p->x));}A.10
B.11
C.20
D.21
考题
函数实现单链表的插入算法,请在空格处将算法补充完整。int ListInsert(LinkList L,int i,ElemType e){ LNode *p,*s;int j; p=L;j=0; while((p!=NULL)(jnext;j++; } if(p==NULL||ji-1) return ERROR; s=(LNode *)malloc(sizeof(LNode)); s-data=e; (1) ; (2) ; return OK;}/*ListInsert*/
考题
写出算法的功能。int L(head){ node * head; int n=0; node *p; p=head; while(p!=NULL) { p=p-next; n++; } return(n); }
考题
函数实现单链表的删除算法,请在空格处将算法补充完整。int ListDelete(LinkList L,int i,ElemType *s){ LNode *p,*q; int j; p=L;j=0; while(( (1) )(jnext;j++; } if(p-next==NULL||ji-1) return ERROR; q=p-next; (2) ; *s=q-data; free(q); return OK;}/*listDelete*/
考题
填空题函数实现单链表的删除算法,请在空格处将算法补充完整。int ListDelete(LinkList L,int i,ElemType *s){ LNode *p,*q; int j; p=L;j=0; while(( (1) )(jnext;j++; } if(p-next==NULL||ji-1) return ERROR; q=p-next; (2) ; *s=q-data; free(q); return OK;}/*listDelete*/
考题
填空题函数实现单链表的插入算法,请在空格处将算法补充完整。int ListInsert(LinkList L,int i,ElemType e){ LNode *p,*s;int j; p=L;j=0; while((p!=NULL)(jnext;j++; } if(p==NULL||ji-1) return ERROR; s=(LNode *)malloc(sizeof(LNode)); s-data=e; (1) ; (2) ; return OK;}/*ListInsert*/
考题
填空题写出算法的功能。int L(head){ node * head; int n=0; node *p; p=head; while(p!=NULL) { p=p-next; n++; } return(n); }
热门标签
最新试卷