pat(A)2-11. 两个有序链表序列的合并

来源:互联网 发布:软件外包公司好不好 编辑:程序博客网 时间:2024/05/21 16:57

代码:

#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;int a[10000000];int main(){    int pos=0;    while(1)    {        int x;        scanf("%d",&x);        if(x==-1)            break;        else            a[pos++]=x;    }    while(1)    {        int x;        scanf("%d",&x);        if(x==-1)            break;        else            a[pos++]=x;    }    if(pos==0)    {        printf("NULL\n");        return 0;    }    sort(a,a+pos);    for(int i=0; i<pos; i++)    {        if(i==pos-1)            printf("%d\n",a[i]);        else            printf("%d ",a[i]);    }    return 0;}


0 0