Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C中从未排序的链表打印唯一的节点元素_C_Linked List - Fatal编程技术网

在C中从未排序的链表打印唯一的节点元素

在C中从未排序的链表打印唯一的节点元素,c,linked-list,C,Linked List,我不知道该怎么说,所以请容忍我,如果我能澄清任何事情,请告诉我。 我有一个以结构表示的节点链表,其中每个节点都有以下内容: 类型、描述、数量 我需要打印出所有独特的“类型”。如果多个节点共享一个类型,我只打印该类型一次 提前谢谢 尝试实现一个集合。然后迭代列表,将类型添加到此集合。我认为这是一个家庭作业,但是较慢的算法应该是这样的 make an array to hold types loop though all the elements search the element in th

我不知道该怎么说,所以请容忍我,如果我能澄清任何事情,请告诉我。 我有一个以结构表示的节点链表,其中每个节点都有以下内容: 类型、描述、数量

我需要打印出所有独特的“类型”。如果多个节点共享一个类型,我只打印该类型一次


提前谢谢

尝试实现一个集合。然后迭代列表,将类型添加到此集合。

我认为这是一个家庭作业,但是较慢的算法应该是这样的

make an array to hold types

loop though all the elements

search the element in the collection
if only found one print the I-th element
if more than one, compare the index, only print if the first found index is equal to the current I, otherwise skip

search the type array for type, if none found
put type in the array made in the first line
and print
otherwise skip