• 大小: 67KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-07
  • 语言: 其他
  • 标签: 排序  合并  

资源简介

实现两个有序单链表的合并。要求:随机创建两个单链表,实现单链表的排序,再对两个有序单链表进行合并。

资源截图

代码片段和文件信息

#include
#include
#include
using namespace std;

#include “d_node.h“
#include “function.h“ 

int main()
{


node * L1 = initRandom(); //初始化随机链表
cout << “The random list 1 as followed:“ << endl;
writelinkedList(L1);
sort(L1); //对随机链表L1进行排序
cout << “The state of list 1 after sorted:“ << endl;
writelinkedList(L1);

node * L2 = initRandom();
cout << “The random list 2 as followed:“ << endl;
writelinkedList(L2);
sort(L2);
cout << “The state of list 2 after sorted:“ << endl;
writelinkedList(L2);

emerge(L1L2); //合并二个有序链表L1L2

cout << “The state of list after emerged:“ << endl;
writelinkedList(L1);

return 0;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        727  2012-03-06 11:27  exp_2\combination.cpp

     文件        605  2012-03-02 20:14  exp_2\d_node.h

     文件       4396  2012-03-04 00:05  exp_2\exp_2.dsp

     文件        535  2012-03-03 14:43  exp_2\exp_2.dsw

     文件      50176  2012-03-06 11:29  exp_2\exp_2.ncb

     文件      48640  2012-03-06 11:29  exp_2\exp_2.opt

     文件        888  2012-03-06 11:27  exp_2\exp_2.plg

     文件       3350  2012-03-06 11:27  exp_2\function.h

     文件     114688  2012-03-06 11:25  实验二.doc

     目录          0  2012-03-06 11:31  exp_2

----------- ---------  ---------- -----  ----

               224005                    10


评论

共有 条评论