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

📄 lianbiao.cpp

📁 C实现的单链表
💻 CPP
字号:
#include<stdio.h>
#include"hanshu.h"
#define NULL 0
#define LEN sizeof(struct stu)
int n=0;
void main()
{
	int k;
	struct stu * head,* stu;
	long del_num;
	printf("创建链表:\n");
	head=creat();
	print(head);
	while(1)
	{
		printf("选择下一步操作:\n1:插入新节点\t2:删除节点\t3:链表倒置\t4:销毁链表\t5:输出文本\t0:退出\n");
		scanf("%d",&k);
		switch(k)
		{
		case 1:
			printf("\ninput the inserted number:\n");
			stu=(struct stu *)malloc(LEN);
			scanf("%ld%f",&stu->num,&stu->score);
			while(stu->num!=0)
			{
				head=in(head,stu);
				print(head);
				printf("\ninput the inserted number:\n");
				stu=(struct stu *)malloc(LEN);
				scanf("%ld%f",&stu->num,&stu->score);
			}
			break;

		case 2:
			printf("\ninput the deleted number:\n");
			scanf("%ld",&del_num);
			while(del_num!=0)
			{
				head=del(head,del_num);
				if(head==NULL)
					break;
				print(head);
				printf("input the deleted number:");
				scanf("%ld",&del_num);
			}
			break;
		
		case 3:
			head=reverse(head);
			print(head);
			break;
		case 4:
			free(head);
			exit(0);
		case 5:
			save(head);
			break;
		case 0:
			goto end;
		default:
			printf("选择错误,请重新选择.");
			break;
		}
	}
end:free(head);
}

⌨️ 快捷键说明

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