⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linklist.c

📁 用C++编写的一个编译器
💻 C
字号:
int printf(char * format, ...);
int scanf(char * format, ...);
void *malloc(int size);
void free(void *pointer);
typedef struct _list{
	int data;
	struct _list*next;
}List;
void insert(List **a, int data)
{
	List *list=*a, *node=malloc(sizeof(List)), *pre=(List*)0;
	node->next=(List*)0;
	node->data=data;
	if(!list)
		*a=node;
	else 
	{
		if(list->data>data)
		{	
			*a=node;
			node->next=list;
		}
		else 
		{
			while(list&&list->data<data)
			{
				pre=list;
				list=list->next;
			}
			node->next= pre->next;
			pre->next=node;
		}
	}
}
int main()
{
	int a;
	List *head=(List*)0, *tmp;
	while(1)
	{
		scanf("%d", &a);
		if(!a)break;
		insert(&head, a);
	}
	while(head)
	{
		tmp=head;
		printf("%d ", head->data);
		head=head->next;
		free(tmp);
	}
	printf("\n");
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -