在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