1 条题解

  • 0
    @ 2024-12-24 9:54:27

    C :

    #include <stdio.h>
    #define MAX 100
    #define M 5
    #define N 4
    typedef int elemtype;
    typedef struct seqlist
    {
    	elemtype A[MAX],B[MAX];
    	int last1,last2;
    }Seqlist;
    
    int main()
    {
    	struct seqlist l;
    	int i,j,k;
    	l.last1=M;
    	l.last2=N;
    	for(i=0;i<l.last1;i++)
    		scanf("%d",&l.A[i]);
    	for(i=0;i<l.last2;i++)
    		scanf("%d",&l.B[i]);
    	i=0;
    	j=0;
    	while(i<l.last1&&j<l.last2)
    	{
    		if(l.A[i]<l.B[j])
    		{
    			printf("%d",l.A[i]);
    			i++;
    		}
    		else
    		{
    			printf("%d",l.B[j]);
    			j++;
    		}
    		if(i<l.last1&&j<l.last2)
    			printf(" ");
    	}
    	if(i==l.last1)
    		for(k=j;k<l.last2;k++)
    			printf(" %d",l.B[k]);
    	else
    		for(k=i;k<l.last1;k++)
    			printf(" %d",l.A[k]);
    	printf("\n");
    }
    
    • 1

    信息

    ID
    1069
    时间
    10000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者