思路:
1、现将数组元素排序
2、再将数组中的元素分别存入链表中
3、合并两个链表
代码实现:
</pre><pre code_snippet_id="1558992" snippet_file_name="blog_20160118_6_8274283" name="code" class="cpp">
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define N 10
typedef struct LNode
{
int key;
struct LNode*next;
} LNode;
void printList(LNode *head) /*打印链表元素*/
{
while(head)
{
printf("%5d",head->key);
head = head->next;
}
printf("\n");
}
int partition(int *a, int low, inthigh) //快排划分元
{
int key =a[low];
while (low< high)
{
while(high > low && a[high] >= key)
--high;
if (low< high)
a[low