题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-05-18 01:09:56

[单项选择](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. *s
B. s
C. *s++
D. (*s)++

更多"(48)~(50)以下程序的功能足:建立一个带有头结点的甲—向链表,并"的相关试题:

[单项选择](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
[填空题]以下程序建立一个带有头结点的单向链表,链表结点中的数据通过键盘输入,当输入数据为-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));
【19】 =a;q->next=p; 【20】 =p;scanf("%d",&a);
p->next=’/0’;return(ph);
main( )
struct list * head;head=creatlist( );
[简答题]【说明】 以下程序的功能是设计一个栈类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( )
[填空题]以下程序用来建立一个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
[填空题]以下程序是建立一个名为myfile的文件,并把从键盘输入的字符存入该文件,当键盘上输入结束时关闭该文件。   #include   main( )   { FILE *fp;   char c;   fp=__________ ;   do{   c=getchar( );   fputs(c,fp);   }while(c!=EOF);   __________ }
[单项选择]第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

我来回答:

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

订单号:

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