-1

これをどのように表現すればよいか正確にはわかりませんでしたので、ご容赦ください。何か明確にすることができるかどうかお知らせください。各ノードが次の内容を持つ構造として表されるノードのリンクされたリストがあります:タイプ、説明、数量

一意の「タイプ」をすべて出力する必要があります。複数のノードがタイプを共有する場合、そのタイプを一度だけ出力します。

前もって感謝します!

4

2 に答える 2

1

セットを実装してみてください。次に、リストを繰り返し、このセットにタイプを追加します。

于 2013-09-30T21:09:20.463 に答える
0

これは宿題だと思いますが、遅いアルゴリズムは次のようになるはずです

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
于 2013-09-30T21:14:22.500 に答える