更多"(48)~(50)题以下程序的功能是:建立一个带布头结点的单向链表,并"的相关试题:
[填空题]以下程序的功能是建立一个带有头结点的单向链表,链表结点中的数据通过键盘输入,当输入数据为-1时,表示输入结束(链表头结点的data域不放数据,表空的条件是ph->next==NULL),请填空。
#include <stdio.h>
struct list int data;struct list *next;;
struct list *creatlist( )
struct list *p,*q,*ph;int a;ph=(struct list*)malloc(sizeof(struct list));
p=q=ph;printf("Input an integer number;entre-1 to end:/n");
scanf("%d",&a);
while(a!=-1)
p=(struct list*)malloc(sizeof(struct list));
______=a;q->next=p;______=p;scanf("%d",&a);
p->next=’/0’;return(ph);
main( )
stuct list * head;head=creatlist( );
[单项选择]以下程序的功能是:建立一个带有头结点的单向链表,并将存储在数组中的字符依次转储到链表的各个结点中,请从与下画线处号码对应的一组选项中选择正确的选项。
#include <stdio.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";
struet node *head ;
head=CreatList(str) ;
…
A. char *
B. stmct node
C. struct node*
D. char
[单项选择]第48~50题基于以下信息。以下程序的功能是:建立一个带有头结点的单向链表,并将存储在数组中的字符依次转储到链表的各个结点中,请从与下划线处号码对应的一组选若中选择出正确的选项。
#include
stuct 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);
...
}
A. char *
B. struct node
C. struct node*
D. char
[单项选择]
(48)~(50)以下程序的功能是:建立一个带有头结点的单向链表,并将存储在数组中的字符依次转存到链表的各个结点中,请从与下划线处号码对应的一组选项中选择出正确的选项。
#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);
A. char*
B. stmct node
C. strumnode*
D. char
[简答题]下列给定程序是建立一个带头结点的单向链表,并用随机函数为各结点数据域赋值。函数fun( )的作用是求出单向链表结点(不包括头结点)数据域中的最大值,并且作为函数值返回。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
typedef struct aa
int data;
struct aa *next;
NODE;
/*************found**************/
fun (NODE *h)
int max=-1;
NODE *p;
p=h->next;
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;
[填空题]下列给定程序中已建立一个带头结点的单向链表,链表中的各结点按结点数据域中的数据递增有序链接。函数fun的功能是:把形参x的值放入一个新结点并插入链表中,使插入后各结点数据域中的数据仍保持递增有序。
请在下画线处填入正确的内容并将下画线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <stdlib.h>
#define N 8
typedef struct list
int data;
struct 1ist * next;
SLIST;
void fun(SLIST * h, int x)
SLIST * P, * q, * s;
s=(SLIST* )malloc(sizeof(SLIST));
/********** found********** /
s->data=______;
q=h;
p=h->next;
while(p! =NULL && x>p->data)
/********** found********** /
q=______;
p=p->next;
s->next=p;
/********** found********** /
q->next=______;
SLIST * creatlist(int * a)
SLIST * h, * p, * q; int i;
h=p=(SLIST * )malloc(sizeof(SLIST));
for(i=0; i<N; i ++)
q=(SLIST * )malloc(sizeof(SLIST));
q->data=a[i]; p->next=q; p=q;
p->next=0;
return h;
voi
[简答题]下列给定程序中,已建立一个带头结点的单向链表,链表中的各结点按结点数据域中的数据递增有序链接。函数fun的功能是:把形参x的值放入一个新结点并插入链表中,使插入后各结点数据域中的数据仍保持递增有序。
请在下画线处填入正确的内容并将下画线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <stdlib .h >
#define N 8
typedef struct list
int data;
struct list * next;
SLIST;
void fun(SLIST * h, int x)
SLIST * p, * q, * s;
s=(SLIST *) malloc (sizeof
(SLIST));
/********** found********** /
s->data= (1) ;
q=h;
p=h->next;
while(p!=NULL && x >p->data)
/********** found********** /
q= (2) ;
p=p->next;
s->next=p;
/********** found********** /
q->next= (3) ;
SLIST * creatlist(int * a)
SLIST * h, * p, * q; int i;
h=p=(SLIST *)malloc (sizeof
(SLIST));
for(i=0; i<N; i++)
q=(SLIST *)malloc (sizeof
(SLIST));
q->data=a[i]; p->next=q; p=q;
[单项选择](48)~(50)以下程序的功能足:建立一个带有头结点的甲—向链表,并将存储在数组中的字符依次转存到链表的各个结点中,请从与下划线处号码对应的一组选项中选择出正确的选项。
#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);
A. char*
B. struct node
C. struct node*
D. char