#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
struct ListNode {
int val;
struct ListNode *next;
};
struct ListNode* deleteDuplicates(struct ListNode* head)
{
struct ListNode dummy;
struct ListNode *prev = &dummy;
dummy.val = INT_MIN;
while (head != NULL) {
if (prev->val != head->val) {
prev->next = head;
prev = head;
}
head = head->next;
}
prev->next = head;
return dummy.next;
}
int main(int argc, char **argv)
{
int i;
struct ListNode *head = NULL;
struct ListNode *prev = NULL;
struct ListNode *p;
for (i = 0; i < argc - 1; i++) {
p = malloc(sizeof(*p));
p->val = atoi(argv[i + 1]);
p->next = NULL;
if (head == NULL) {
head = p;
prev = head;
} else {
prev->next = p;
prev = p;
}
}
p = deleteDuplicates(head);
while (p != NULL) {
printf("%d ", p->val);
p = p->next;
}
printf("\n");
return 0;
}
m0_57195758
- 粉丝: 2716
- 资源: 715
最新资源
- 由https://download.csdn.net/download/weixin-45944596/89887488的算法
- 技术资料分享ARM9嵌入式技术及嵌入式Linux高级实验教程.zip
- 技术资料分享ARM.linux无线通讯实验AT91.zip
- Matlab车型识别系统[Matlab面板版].zip
- 【Unity GUI资源包】4k Full Fantasy GUI + over 400 png + samples
- Matlab面板版水果草莓检测[Matlab面板版].zip
- 《Machine Learning》课程PPT-吴恩达14
- Matlab面板版汉字定位检测识别[Matlab面板版].zip
- 中国传媒业人工智能应用发展图谱
- 生成式人工智能大模型及其电力系统数智化应用前沿报告
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈