题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-22 11:22:29

[单项选择]以下程序的功能是:建立一个带有头结点的单向链表,并将存储在数组中的字符依次转存到链表的各个结点中,请为下划线处选择正确的选项。
#include < stdlib. h >
stuct node
char data; struct node * next; ;
( ) CreatList(char * s)
struet node * h, * p, * q;
h = (struet node * ) ma]loc(sizeof(struct node) );
p=q=h;
while( * s! =’/0’)
p = ( struct node * ) ma]loc ( sizeof( struct node) );
p- >data= *s; q- >next=p; q=p;
s++;

p- > next =’/0’;
return h
main( )
char str[ ] = "link list";
struet node * head;
head = CreatList (str);
A. char *
B. struet node
C. struct node *
D. char

更多"以下程序的功能是:建立一个带有头结点的单向链表,并将存储在数组中的字符"的相关试题:

[简答题]【说明】 以下程序的功能是设计一个栈类stack<T>,并建立一个整数栈。 【程序】 #include < iostream. h > #include < stdlib. h > const int Max =20; //栈大小 template < class T > class stack{ //栈元素数组 T s[Max]; //栈顶下标 int top; public: stack( ) { top =-1; //栈顶初始化为-1 } void push( const T &item); //item入栈 T pop( ); //出栈 int stackempty( ) const; //判断栈是否为 }; template < class T > void stack <T >::push(const T &item) { if(top== (1) ) { cout <<"栈满溢出" <<endl; exit(1); } top ++ s[top] = item; } template < class T > T stack<T> ::pop( ) { T temp; if(top== (2) ) { cout <<"栈为空,不能出栈操作" < < endl; exit(1); } temp =s[top]; top --; return temp; } template < class T > int stack < T >:: stackempty( ) const { return top == -1; { void main( ) { stack <int> st; int a[] ={1,2,3,4,5}; cout <<"整数栈" <<e
[简答题]【说明】
以下程序的功能是设计一个栈类stack<T>,并建立一个整数栈。
【程序】
#include < iostream. h >
#include < stdlib. h >
const int Max =20; //栈大小
template < class T >
class stack //栈元素数组
T s[Max]; //栈顶下标
int top;
public:
stack( )

top =-1; //栈顶初始化为-1

void push( const T &item); //item入栈
T pop( ); //出栈
int stackempty( ) const; //判断栈是否为
;
template < class T >
void stack <T >::push(const T &item)

if(top== (1) )

cout <<"栈满溢出" <<endl;
exit(1);

top ++
s[top] = item;

template < class T >
T stack<T> ::pop( )

T temp;
if(top== (2) )

cout <<"栈为空,不能出栈操作" < < endl;
exit(1);

temp =s[top];
top --;
return temp;

template < class T >
int stack < T >:: stackempty( )
[单项选择]第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
[填空题]以下程序的功能是建立一个带有头结点的单向链表,链表结点中的数据通过键盘输入,当输入数据为-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( );
[填空题]以下程序用来建立一个10*10矩阵,该矩阵两条对角线上的元素为1,其余元素为0,请补充完该程序。
该程序运行结果见下图。
Private Sub Form_ click( )
Dim s(10, 10) As Integer
For n = 1 To 10
For m = 1 To 10
If 【12】 Or 【13】 Then
s (n, m) = 1
Else
s (n, m) = 0
End If
Next m
Next n
For n = 1 To 10
For 【14】
Picturel. Print Tab(m * 3); s(n, m)
Next m
Print
Next n
End Sub
[填空题]以下程序需要实现的功能是:在C盘根目录下建立一个名为Students.txt的顺序文件。单击命令按钮后,输入4个学生的个人信息,包括name、sex和age,将这些信息写入文件中。请填空。
Private Sub Form_Click( )
Open 【9】 For Output As #1
For i=1 To 4
name=InputBox("姓名")
age=InputBox("年龄")
sex=InputBox("性别")
Write 【10】
Next i
Close #1
End Sub
[单项选择](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
[单项选择]以下程序的功能是:建立一个带有头结点的单向链表,并将存储在数组中的字符依次转存到链表的各个结点中,请填空。
#include <stdlib.h>
stuct node
char data; struet node * next; ;
stntct node * CreatList(char * s)
struet 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 = ( )
q- >next=p;
q=p;
a++;
p- > next =’/0’;
return h;

main( )
char str[ ]= "link list";
struet node * head;
head = CreatList(str);
A. *s
B. s
C. *s++
D. (*s)++

我来回答:

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

订单号:

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