單鏈表中重複元素的刪除

2022-06-12 18:57:08 字數 701 閱讀 1301

problem description

按照資料輸入的相反順序(逆位序)建立乙個單鏈表,並將單鏈表中重複的元素刪除(值相同的元素只保留最後輸入的乙個)。

input

第一行輸入元素個數n; 

第二行輸入n個整數。

output

第一行輸出初始鍊錶元素個數; 

第二行輸出按照逆位序所建立的初始鍊錶;

第三行輸出刪除重複元素後的單鏈表元素個數;

第四行輸出刪除重複元素後的單鏈表。

example input

1021 30 14 55 32 63 11 30 55 30

example output

1030 55 30 11 63 32 55 14 30 21

730 55 11 63 32 14 21

#include #include #include struct node

;struct node *creat(int n)

return head;

};int del(struct node *head,int n)

else

}if(t->next==null)

}p=p->next;

}return n;

}void show(struct node *head)

}int main()

單鏈表中重複元素的刪除

資料結構實驗之鍊表七 單鏈表中重複元素的刪除 timelimit 1000ms memory limit 65536k 題目描述 按照資料輸入的相反順序 逆位序 建立乙個單鏈表,並將單鏈表中重複的元素刪除 值相同的元素只保留最後輸入的乙個 輸入第一行輸入元素個數n 第二行輸入 n個整數。輸出第一行輸...

單鏈表中重複元素的刪除

資料結構實驗之鍊表七 單鏈表中重複元素的刪除 time limit 1000ms memory limit 65536k 題目描述 按照資料輸入的相反順序 逆位序 建立乙個單鏈表,並將單鏈表中重複的元素刪除 值相同的元素只保留最後輸入的乙個 輸入第一行輸入元素個數n 第二行輸入n個整數。輸出第一行輸...

單鏈表中重複元素的刪除

time limit 1000 ms memory limit 65536 kib submit statistic discuss problem description 按照資料輸入的相反順序 逆位序 建立乙個單鏈表,並將單鏈表中重複的元素刪除 值相同的元素只保留最後輸入的乙個 input 第一...