ylm


私信TA

用户名:ywjylm

访问量:6505

签 名:

等  级
排  名 5757
经  验 1443
参赛次数 1
文章发表 9
年  龄 0
在职情况 学生
学  校 华南农业大学
专  业

  自我简介:

解题思路:





注意事项:





参考代码:

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

#include <string.h>

struct node

{

    int x;

}Lc[200+10],Lb[100+10],La[110];

void Listinsert(struct node *p,struct node *q);

void show(struct node *p,int n);

int main()

{

    int i,j,k,flag=1,len_a,len_b,len_c,y;

    while(scanf("%d",&y)!=EOF)

    {

        if(flag%2)

        {

            for(i=0;i<y;i++)

            {

                scanf("%d",&La[i].x);

            }

            len_a=y;

        }

        else

        {

            for(i=0;i<y;i++)

            {

                scanf("%d",&Lb[i].x);

            }

            len_b=y;

        }

        flag++;

        if(flag%2)

        {

            len_c=len_a+len_b;

            i=k=j=0;

            while(i<len_c&&j<len_a&&k<len_b)

            {

               if(La[j].x>=Lb[k].x)

               {

                   Listinsert(&Lc[i++],&Lb[k++]);

               }

               else

                Listinsert(&Lc[i++],&La[j++]);

            }

            while(j<len_a)

            {

               Listinsert(&Lc[i++],&La[j++]);

            }

            while(k<len_b)

            {

                Listinsert(&Lc[i++],&Lb[k++]);

            }

            show(Lc,len_c);

        }

    }

    return 0;

}


void Listinsert(struct node *p,struct node *q)

{

    *p=*q;

}

void show(struct node *p,int n)

{

    struct node *iii;

    for(iii=p;iii<p+n;iii=iii+1)

    {

        if(iii<=p)

            printf("%d",iii->x);

        else

            printf(" %d",iii->x);

    }

    printf("\n");

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区