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

📄 list.cpp

📁 编写程序
💻 CPP
字号:
// List.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "GlobalDefining.h"
#include "ListStruct.h"
#include <iostream.h>

extern STATUS InitList(LinkList &L);

extern void DestroyList(LinkList &L);
extern STATUS InsertOrderList(LinkList &L, int data);	//有序插入,按非递减插入
extern void MergeList(LinkList &L3, LinkList &L1, LinkList &L2);	//将L1和L2归并入L3
extern void printList(LinkList &L);//将L输出



int main(int argc, char* argv[])
{
	LinkList L1, L2;
	InitList(L1);
	InitList(L2);

	//输入L1
	cout << "从键盘输入一批整数,以建立链表L1,以输入-1为结束:" << endl;
	int x;
	cin >>x;
	while(x != -1)
	{
		InsertOrderList(L1, x);
		cin >> x;
	}
	cout<<"排序后的L1:";
	printList(L1);
	
	//输入L2
    cout << "从键盘输入一批整数,以建立链表L2,以输入-1为结束:" << endl;
    int y;
    cin >>y;
    while(y != -1)
	{
        InsertOrderList(L2, y);
        cin >> y;
	}
	cout<<"排序后L2:";
	printList(L2);
    LinkList L3;
    InitList(L3);
    MergeList(L3,L1,L2);
    cout<<"归并后的L3为:"<<endl;
	printList(L3);


//归并L1和L2,成为L3,并将归并后的L3输出
	
	return 0;
}

⌨️ 快捷键说明

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