题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-03 09:47:31

[简答题]请编写函数fun( ),它的功能是:将带头结点单向链表按data域由大小排序(排序时不考虑头结点),主函数用随机函数为各结点data域赋值,头结点data域赋值为0。
注意:部分原程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
[试题源程序]
#include <stdio.h>
#include <conio.h>
struct aa

int data;
struct aa*next;

void fun(struct aa*p)


main( )

int i,n,m=100;
struct aa*h=NULL,*s=NULL,
*p=NULL;
clrscr( );
S=(struct aa*)malloc(sizeof(struct aa));
h=s;h->data=0;h->next=NULL;
printf("Please input n:");
scanf("%d",&n);
for(i=1;i<=n;i++)

p=(struct aa*)malloc(sizeof(struct aa));
p->data=rand( )%m;p->next=NULL;
printf("%d",p->data);
s->next=p;s=s->next;

fun(h);
printf("/n");
for(h=h->next;h!=NULL;h=h->nnext)
printf("%d",h->data);

更多"请编写函数fun( ),它的功能是:将带头结点单向链表按data域由大"的相关试题:

[简答题]

请编写函数fun( ),它的功能是:将带头结点单向链表按data域由大到小排序(排序时不考虑头结点),主函数用随机函数为各节点data域赋值,头结点data域赋值为0。
[注意] 部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
[试题源程序]
#include <stdio.h>
#include<coni0.h>
struct as

int data;
struct aa *next;
;
void fun(struct aa *p)


main( )

int i, n, m=100;
struct aa *h=NULL, *s=NULL,
*p=NULL;
clrscr( )
s=(struct aa*) malloc(siZeof(struct aa));
h=s; h->data=0; h->next=NULL;
printf("Please input n:");
scanf("%d", &n);
for(i=1; i<=n; i++)

p=(struct aa*) malloc(sizeof(struct aa));
p->data=rand( )%m; P->next=NULL;
printf("%d", P->data);
s->next=p; s=s->next;

fun(h);
printf("/n");
for(h=h->next; h!=NULL; h=h->nnext)
printf("%d", h->data);


[填空题]请补充fun函数,该函数的功能是:将带头结点的单向链表逆置。即若原链表中从头至尾结点数据域依次为:2、4、6、8、10,逆置后,从头至尾结点数据域依次为:10、8、6、4、2。
[注意] 部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
[试题源程序]
#include <stdio.h>
#include <stdlib.h>
#define N 5
typedef Struct node
int data;
struct node *next;
NODE;
void fun(NODE *h)

NODE *p, *q, *r;
p= (1) ;
if ( (2) ) return;
q=P->next;
P->next=NULL;
while (q)

r=q->next;
q->next=p;
p=q;
q= (3) ;

h->next=p;

NODE *creatlis (int a[])

NODE *h, *p, *q; int i;
h= (NODE *)malloc(sizeof(NODE));
h>next=NULL:
for(i=0; i<N; i++)

q=(NODE *)malloc(sizeof(NODE));
q->data=a[i];
q->next=NULL;
if(h->next==NULL)
h->next=p=q;
else

p->next=q; p=q;


return h;

void ou list(NODE *h)

NODE *p;
p=h->next;
if(p==NU
[判断题]对数据清单中的数据进行排序时,可按某一字段进行排序,也可按多个字段进行排序,当按多个字段进行排序时称为多重排序。( )
[单项选择]

按排序策略分类,冒泡排序属于 (59) 。对n个记录的文件进行排序时,如果待排序文件中的记录初始时为所要求次序的逆序,则冒泡排序过程中需要进行 (60) 次元素值的比较。

(59)处填()。
A. 插入排序
B. 选择排序
C. 交换排序
D. 归并排序
[填空题]多字段排序时,排序的优先级是 【11】
[填空题]多字段排序时,排序的优先级是 【12】
[填空题]排序时如果选取了多个字段,则结果是按 【6】 开始排序的。
[单项选择]

对由n个记录所组成的有序关键码排序时,下列各常用排序算法的平均比较次数分别是:二路归并排序为 (1) ,冒泡排序 (2) ,快速排序为 (3) 。其中,归并排序和快速排序所需要的辅助存储分别是 (4) (5)

4()
A. O(1)
B. O(nlog2n)
C. O(n)
D. O(n2)
E. O(n(log2n)2)
F. O(log2n)

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码