解题思路:
注意事项:
参考代码:
#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 人评分
C语言考试练习题_排列 (C语言代码)浏览:719 |
2004年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:1327 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:372 |
1050题解(结构体数组与结构体指针的使用)浏览:1106 |
钟神赛车 (C语言代码)浏览:590 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:527 |
众数问题 (C语言代码)浏览:668 |
【魔板】 (C++代码)浏览:1156 |
母牛的故事 (C语言代码)浏览:476 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:612 |