ylm


私信TA

用户名:ywjylm

访问量:6449

签 名:

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

  自我简介:

解题思路:





注意事项:





参考代码:

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

#include <string.h>

struct node

{

    int x;

}t,La[200+10],Lb[100+10];

int LocateElme(struct node *p,int t,int j);

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

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

int main()

{

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

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

    {

        if(flag%2)

        {

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

          {

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

          }

          len_a=y;

          show(La,len_a);

        }

        else

        {

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

            {

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

            }

            len_b=y;

            show(Lb,len_b);

        }

        flag++;

        if(flag%2)

        {

            j=len_a;

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

          {

             k=LocateElme(La,Lb[i].x,j);

             if(k==0)

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

             show(La,j);}

             else

                show(La,j);

          }

          printf("\n");

        }

    }

    return 0;

}

int LocateElme(struct node *p,int t,int j)

{

    int flag=0;

    struct node *ii;

    for(ii=p;ii<p+j;ii=ii+1)

    {

        if(ii->x==t)

            {flag=1;break;}

    }

    return flag;

}

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+n-1)

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

        else

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

    }

}


 

0.0分

2 人评分

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

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区