#include <bits/stdc++.h>

using namespace std;

struct node
{
int data;
struct node *next;
};
struct node *creat(int n)
{
struct node *head,*tail,*p;
head=(struct node*)malloc(sizeof(struct node));
head->next=NULL;
tail=head;
int i;
for(i=0;i<n;i++)
{
p=(struct node*)malloc(sizeof(struct node));
p->next=NULL;
scanf("%d",&p->data);
tail->next=p;
tail=p;
}
return head;
}
int main()
{
struct node *head,*head1,*head2,*p,*p1,*p2,*tail;
head=(struct node*)malloc(sizeof(struct node));
head->next=NULL;
tail=head;
int n,m;
scanf("%d %d",&n,&m);
head1=creat(n);
head2=creat(m);
p1=head1->next;
p2=head2->next;
free(head1);
free(head2);
while(p1&&p2)
{
if(p1->data<p2->data)
{
tail->next=p1;
tail=p1;
p1=p1->next;
tail->next=NULL;
}
else
{
tail->next=p2;
tail=p2;
p2=p2->next;
tail->next=NULL;
}
}
if(p1) tail->next=p1;
else tail->next=p2;
for(p=head->next;p!=NULL;p=p->next)
{
if(p==head->next) printf("%d",p->data);
else printf(" %d",p->data);
}
return 0; }

数据结构实验之链表四:有序链表的归并(SDUT 2119)的更多相关文章

  1. 数据结构实验之排序四:寻找大富翁(SDUT 3401)

    #include <stdio.h> #include <stdlib.h> #include <string.h> void Swap(int a[], int ...

  2. 数据结构实验之查找四:二分查找(SDUT 3376)

    #include <stdio.h> #include <string.h> #include <stdlib.h> int a[1000005]; int fin ...

  3. SDUT OJ 数据结构实验之图论四:迷宫探索

    数据结构实验之图论四:迷宫探索 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descrip ...

  4. SDUT OJ 数据结构实验之二叉树四:(先序中序)还原二叉树

    数据结构实验之二叉树四:(先序中序)还原二叉树 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem ...

  5. SDUT OJ 数据结构实验之排序四:寻找大富翁

    数据结构实验之排序四:寻找大富翁 Time Limit: 200 ms Memory Limit: 512 KiB Submit Statistic Discuss Problem Descripti ...

  6. SDUT 3401 数据结构实验之排序四:寻找大富翁.!

    数据结构实验之排序四:寻找大富翁 Time Limit: 150MS Memory Limit: 512KB Submit Statistic Problem Description 2015胡润全球 ...

  7. SDUT 3376 数据结构实验之查找四:二分查找

    数据结构实验之查找四:二分查找 Time Limit: 20MS Memory Limit: 65536KB Submit Statistic Problem Description 在一个给定的无重 ...

  8. SDUT 3361 数据结构实验之图论四:迷宫探索

    数据结构实验之图论四:迷宫探索 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 有一个地下迷 ...

  9. SDUT 3343 数据结构实验之二叉树四:还原二叉树

    数据结构实验之二叉树四:还原二叉树 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 给定一棵 ...

  10. SDUT-3376_数据结构实验之查找四:二分查找

    数据结构实验之查找四:二分查找 Time Limit: 30 ms Memory Limit: 65536 KiB Problem Description 在一个给定的无重复元素的递增序列里,查找与给 ...

随机推荐

  1. Linux 多命令语句与重定向

    多命令语句 Linux中我们在shell输入命令一般是一条一条执行,但是我们同样可以用一行语句写出多命令,下面就举出几个常见的方法 “;”分号用法 方式:command1 ; command2 用;号 ...

  2. 【AC自动机】病毒

    [题目链接] https://loj.ac/problem/10062 [题意] 寻找一个没有模式串为子串的无限01串.是否存在. [题解] 其实就是用dfs找一个环. 1.环需要从根结点出发找到这个 ...

  3. linux 安装apache

    APR and APR-Util包 下载地址:http://apr.apache.org PCRE 下载地址:http://www.pcre.org Apache Server2.4 下载地址:htt ...

  4. 系统学习机器学习之神经网络(三)--GA神经网络与小波神经网络WNN

    系统学习机器学习之神经网络(三)--GA神经网络与小波神经网络WNN 2017年01月09日 09:45:26 Eason.wxd 阅读数 14135更多 分类专栏: 机器学习   1 遗传算法1.1 ...

  5. 在Linux上安装和配置CSF(配置服务器安全和防火墙)

    CSF是国外一家小公司开发的linux系统免费防火墙,它基于iptables工作,能有效缓解服务器压力,具有自动屏蔽暴力破解密码IP.管理开放端口.免疫轻量DDos和CC等等功能,同时,安装和使用也极 ...

  6. android-studio-ide 安装到运行第一个helloword,坑记录

    1: 安装是提示  机器虚拟化问题,系统如开启了Hyper-V,必须关闭服务 2:安装完后,建立第一个项目,gradle build 一直转圈,最后报错 Gradle project sync fai ...

  7. 【php设计模式】观察者模式

    当对象间存在一对多关系时,则使用观察者模式.比如,当一个对象被修改时,则会自动通知它的依赖对象.观察者模式属于行为型模式. <?php class Subject{ private $obser ...

  8. css height属性中的calc方法

    例如父盒子是100%的高度 盒子里面的head部分固定位140px 内容部分始终为剩余的全部高度 height: calc(100% - 140px); 切结"+或-"两边要有空格 ...

  9. 2018 年 IoT 那些事儿

    本文作者:murphyzhang.xmy.fen @腾讯安全云鼎实验室   2018年,是 IoT 高速发展的一年,从空调到电灯,从打印机到智能电视,从路由器到监控摄像头统统都开始上网.随着5G网络的 ...

  10. Centos7.7安装swoole

    系统版本:centos 7.7(查看系统版本:cat /etc/redhat-release) 执行命令安装swoole: yum update -y && yum remove ph ...