题目详情
当前位置:首页 > 计算机考试 > 初级程序员
题目详情:
发布时间:2023-10-09 20:52:16

[简答题][说明]
本程序包含的函数及其功能说明如下:
(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 );

更多"[说明] 本程序包含的函数及其功能说明如下: (1)函数first"的相关试题:

[填空题][说明]
本程序的函数sum(int,i int total,int sigma,int rear,int d[],int n)用来从已知数组d的前n个元素中找出所有部分元素序列之和等于total的元素序列,约定数组d的元素都是正整数,且都小于等于total。
函数sum使用递归方法找出全部解答。参数i表示递归函数当前考虑元素d[i],参数sigma是调用前已选取的部分序列的元素和,参数rear是后面还未考虑的那部分元素的元素和。
函数对元素d[i]有两种可能的选择方案:
(1)考虑元素d[i]被包含在新的部分元素序列中的可能性。如果在当前部分元素序列之后接上d[i],新序列的元素和不超过total,则函数将d[i]包含在当前部分元素序列中。如果新的部分元素序列的元素和等于total时,新的部分元素序列就是一个解答,函数将其输出;否则,若继续考虑后面的元素还有可能找到解答时,函数就递归去考虑后面的元素,寻找解答。最后,函数应恢复原来部分元素序列中不包含d[i]的状态。
(2)考虑元素d[i]不被包含在新的部分元素序列中的可能性。如果继续向d[i]之后考虑还是有希望能得到和为total的部分元素序列,函数将新序列不包含d[i也作为一种可能的选择,并递归去考虑后面的元素,寻找解答。
[程序1—7]
#include<stdio.h>
#define N 100
int a[N];
int fig[N];
sum(int i,im total,int sigma,int rear,int d[],int t)
int j;
/*考虑元素d[i]被包含在新的部分元素序列中的可能性*/
if(sigma+d[i]<=total) /*如果d[i]与当前序列的和不超过total*/
flg[i]=1; /*d[i]被考虑在当前部分元素序列中*/
if( (1) ==total)
/*输出解*/
for(j=0;flg[j]==0;j++);
printf("%4d=%d",total,d[j]);
for(j++;j<=i;j++)
if(flg
[填空题]阅读以下函数说明和C语言函数,将应填入 (n) 处的字句写在对应栏内。
[说明1]
本程序输入一字符串,并将其中的大写字母变成小写字母。
[C函数1]
#include<stdio.h>
void main( )
int i=0;
char s[120];
printf("Enter a string./n");
scanf("%s",s);
while( (1) )
if( (2) )
s[i]=s[i]-’A’+’a’;
i++;

printf("%s/n",S);

[说明2]
本程序用二分法,在已按字母次序从小到大排序的字符数组list[len]中,查找字符c,若c在数组中,函数返回字符c在数组中的下标,否则返回-1。
[C函数2]
int search(char list[],char c,int len)
( intlow=0,high=len-1,k;
while( (3) );
k=(10w+high)/2;
if( (4) ) return k;
else if( (5) )high=k-1;
else low=k+1;
return -1;

[简答题]写出Excel常用函数名及其功能(写出4种即可)。
[填空题]阅读以下函数说明和C语言函数,将应填入 (n) 处的字句写在对应栏内。
[说明]
本程序实现对指定文件内的单词进行计数。其中使用二叉树结构来保存已经读入的不同单词,并对相同单词出现的次数进行计数。此二叉树的左孩子结点的字符串值小于父结点的字符串值,右孩子结点的字符串值大于父结点的字符串值。函数getword(char*filename,char*word)是从指定的文件中得到单词。char*strdup(char*S)是复制S所指向的字符串,并返回复制字符串的地址。
[C程序]
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define MAXWORD 100
struct node {
char*word;
int count;
struct node*left;
struct node*right;
}
struct node*addtree(struct node*P,char*w)
{ int cond;
if(p==NULL){ /*向树中插入结点*/
P=(struct node*)malloc(sizeof(struct node));
P->word=strdup(w);
P->count=1;
(1) ;
}
elseif((oond=strcmp(w,p->word))==0) (2) ;
else if(cond<0)p->left= (3) ;
else p->right= (4) ;
return p;
}
main( )
{ Struct no
[简答题][说明]
本程序实现了雇员信息管理功能,其中封装了雇员信息及其设置、修改、删除操作。已知当输入为“Smith 31 2960.0”时,程序的输出是:
姓名:Smith 年龄:31 工资:2960
姓名:Smith 年龄:31 工资:3500
姓名:Mary 年龄:23 工资:2500
[C++程序]
#include <iostream.h>
#include <string.h>
class employee
char *name; //雇员姓名
short age; //年龄
float salary;//工资
public:
employee( );
void set_name(char *);
void set_age(short a) age=a;
void set_salary(float s) salary=s;
(1) ;
~ employee( )delete[] name;
;
employee::employee( ) name="";
age=0;
salary=0.0;
void employee::set_name(char *n)
name=new char[strlen(n)+1];
(2) (name,n);void employee::print( )
cout<<"姓名":"<<name<<" 年龄:"<<agc<<" 工资:" <<salary<<endl;void main( )
char *na;
short ag=0;
float sa=0;
(3) ;
na=new char[10];
cin>>na>>ag>>sa;
emp.set_name(na);
emp.set_age(ag);
emp.set_salary(sa);
emp.print( );
(4) (3500
[填空题]请补充main函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的所有字符全部删除。结果仍然保存在原串中。
例如,输入“abcdef”,指定字符为‘e’,则输出“abcd”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio. h>
#define N 80
main ( )

int i=0;
char str [N];
char ch;
clrscr ( );
printf"/n Input a string:/n");
gets (str);
printf("kn Input a charator;/n");
scanf ("%c", &ch);
while (str [i] !=’/0’)

if (str [i]==ch)
【1】
【2】 ;

str[i]= 【3】 ;
printf"/n*** display string ***/n");
puts (str);

[填空题]如下类定义中包含了构造函数和拷贝构造函数的原型声明,请在横线处填写正确的内容,使拷贝构造函数的声明完整。 class myClass{ private: int data; public: myClass(int value); //构造函数 myClass(const______anotherObject); //拷贝构造函数 }
[填空题]如下类定义中包含了构造函数和复制构造函数的原型声明,请在画线处填写正确的内容,使复制构造函数的声明完整。 class my(21ass{ private: int data: public:: MyClass(int value);//构造函数 MyClass(const______anotherObject); //复制构造函数
[简答题]【说明】
本程序利用非递归算法实现二叉树后序遍历。
【函数】
#include<stdio.h>
#include<stdlib.h>
typedef struct node/*二叉树的结点数据结构类型*/
char data;
struct node *left;
struct node *right;
BTREE;
void SortTreelnsert(BTREE **tree, BTREE *s)

if(*tree==NULL)*tree=s;
else
if(s->data<(*tree)->data)
SortTreelnsert( (1) ,s);
else if(s->data>=(*tree)->data)
SortTreelnsert( (2) ,s);

void TraversalTree(BTREE *tree)

BTREE *stack[1 000],*p;
int tag[1000],top=0;
p=tree;
do
while(p !=NULL)

stack[++top]=p;
(3) ;
tag[top]=0; /*标记栈顶结点的左子树已进行过后序遍历*/

while(top>0&& (4) )/*栈顶结点的右子树是否被后序遍历过*/

p=stack[top--];
putchar(p->data);

if(top>0)/*对栈顶结点的右子树进行后序遍历*/

(5) ;
tag[top]=1;

while(

我来回答:

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

订单号:

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