几个问题(我已经回答了硬件问题) [英] Few Questions (HW questions already answered by me)

查看:72
本文介绍了几个问题(我已经回答了硬件问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是有几个问题也许你们可以验证

正确性:

..

----- -------------------------------------------------- -------------------------------------------------- ---------------


21)显示如何插入新元素new_element进入

链表my_list


my_list new_element = my_list-> next;


- -------------------------------------------------- -------------------------------------------------- -------------------


仅供我验证:如果要在C中创建链接列表,请执行

你一直需要一个结构吗?我知道如何以这种方式创造它,

但是如果还有其他方法就好奇。


谢谢..

解决方案

pa ****** @ gmail.com 写道:


我只是有几个问题也许你们可以验证

正确性:




21)显示如何插入新元素new_element进入一个

链表'my_list


my_list new_element = my_list-> next;



这不会插入任何东西。它只是一个初始化的
。推测my_list是指针类型。


仅供我验证:如果你想在C中创建一个链接列表,你需要

一直都是一个结构?我知道如何以这种方式创造它,

,但只是好奇,如果还有其他方法。



通常链接列表除了链表指针本身外,还会在每个节点中包含某种辅助数据

。 />
C提供的绑定不同类型数据项的方式

在一个包中使用结构。


其他方式也许是可能的,但他们可能会更加尴尬。例如,我想你可以使用两个或多个
多个指针的数组来组成一个链表节点,但是这样做通常不合理
。 (我可以在C中看到一个Lisp

实现可能想要这样做,但即便如此,它可能会更好地使用结构。)

-

int main(void){char p [] =" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\

\ n",* q =" kl BIcNBFr .NKEzjwCIxNJC" ;; int i = sizeof p / 2; char * strchr(); int putchar(\

); while(* q){i + = strchr(p,* q ++) - p ; if(i> =(int)sizeof p)i- = sizeof p-1; putchar(p [i] \

);} return 0;}


pa******@gmail.com 写道:
< blockquote class =post_quotes>
我只是有几个问题也许你们可以验证

正确性:



------------------------------------------------ -------------------------------------------------- ----------------------


21)显示如何插入新元素new_element进入

链表my_list


my_list new_element = my_list-> next;


- -------------------------------------------------- -------------------------------------------------- -------------------



你确定这是正确答案吗?


仅供我验证:如果你想在C中创建一个链接列表,那么你需要一个结构吗?我知道如何以这种方式创造它,

,但只是好奇,如果还有其他方法。



还有其他方法,但它们相同。例如,

如果你的元素是一堆指针,而不是一个结构

包含指向下一个元素和数据指针的指针,你

可以使用两个指针的数组,而不是element->接下来使用

元素[0],而不是element->数据使用元素[1]。它不会更可读,它不会更有效率,它不会是一个好主意。但这是可能的。




""" pa ****** @ gmail。 comDéóáì(á):

"""


我只有几个问题,也许你们可以验证

正确性:



------------------------------------------- -------------------------------------------------- ---------------------------


21)显示如何插入新元素 ; new_element"进入

链表my_list


my_list new_element = my_list-> next;


- -------------------------------------------------- -------------------------------------------------- -------------------


仅供我验证:如果要在C中创建链接列表,请执行

你一直需要一个结构吗?我知道如何以这种方式创建它,

但是如果还有其他方法就好奇。


谢谢..


http://magegame.ru/?rf=626f6764616e


Hi, I just have a few questions maybe you guys can verify for
correctness:
..
------------------------------------------------------------------------------------------------------------------------

21) Show how you would insert a new element "new_element" into a
linked list "my_list"

my_list new_element = my_list->next;

------------------------------------------------------------------------------------------------------------------------

Just for MY verification: If you want to create a link list in C, do
you need a structure all the time? I know how to create it that way,
but just curious if there are any other ways.

Thanks..

解决方案

pa******@gmail.com writes:

Hi, I just have a few questions maybe you guys can verify for
correctness:
.

21) Show how you would insert a new element "new_element" into a
linked list "my_list"

my_list new_element = my_list->next;

That doesn''t insert anything into anything. It''s just an
initialization. Presumably my_list is a pointer type.

Just for MY verification: If you want to create a link list in C, do
you need a structure all the time? I know how to create it that way,
but just curious if there are any other ways.

Normally a linked list will include some kind of auxiliary data
in each node, in addition to the linked list pointers themselves.
The way C provides to bind together different types of data items
in a single package is to use a structure.

Other ways may be possible, but they''d probably be much more
awkward. For example, I suppose you could use an array of two or
more pointers to form a linked list node, but it wouldn''t
normally be sensible to do so. (I could see a Lisp
implementation in C might want to do that, but even then it might
be better to use a structure.)
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}


pa******@gmail.com wrote:

Hi, I just have a few questions maybe you guys can verify for
correctness:
.
------------------------------------------------------------------------------------------------------------------------

21) Show how you would insert a new element "new_element" into a
linked list "my_list"

my_list new_element = my_list->next;

------------------------------------------------------------------------------------------------------------------------

Are you sure that is the correct answer?

Just for MY verification: If you want to create a link list in C, do
you need a structure all the time? I know how to create it that way,
but just curious if there are any other ways.

There are other ways, but they amount to the same thing. For example,
if your elements are a bunch of pointers, instead of a structure
containing a pointer to the next element and the data pointer, you
could use an array of two pointers, instead of element->next use
element[0], and instead of element->data use element[1]. It would not
be more readable, it would not be more efficient, it would not be a
good idea. But it''s possible.



"""pa******@gmail.com Déóáì(á):
"""

Hi, I just have a few questions maybe you guys can verify for
correctness:
.
------------------------------------------------------------------------------------------------------------------------

21) Show how you would insert a new element "new_element" into a
linked list "my_list"

my_list new_element = my_list->next;

------------------------------------------------------------------------------------------------------------------------

Just for MY verification: If you want to create a link list in C, do
you need a structure all the time? I know how to create it that way,
but just curious if there are any other ways.

Thanks..


http://magegame.ru/?rf=626f6764616e


这篇关于几个问题(我已经回答了硬件问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆