69,336
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
void Sort(int num[],int i);
int main(void)
{
int num1[100],num2[50],i,j,k;
printf("Please input some digits for the original array.\n");
printf("Be aware that the amount of digits shouldn't be bigger than 50.\n");
for(i=0;getchar()!=EOF;i++)
{
scanf("%d",&num1[i]);
}
printf("\n");
Sort(num1,i+1);
printf("Please input some digits for the array to be inserted.\n");
for(j=0;getchar()!=EOF;j++)
{
scanf("%d",&num2[j]);
}
printf("\n");
for(k=0;k<=j;k++)
{
num1[i+k+1]=num2[k];
}
Sort(num1,i+j+2);
printf("The sorted array which has been inserted another array is:\n");
for(k=0;k<i+j+2;k++)
{
printf("%d\t",num1[k]);
if((k+1)%6==0)
{
printf("\n");
}
}
printf("\n");
system("PAUSE");
return 0;
}
void Sort(int num[],int i)
{
int j,t,temp;
for(j=0;j<i;j++)
{
for(t=0;t<i-j;t++)
{
if(num[t]>num[t+1])
{
temp=num[t];
num[t+1]=num[t];
num[t]=temp;
}
}
}
}