``````#include <stdio.h>
int sort(int *p, int x)
{
int m, n, i;
for (i=0; i<x-1; i++){
for (m=0; m<x-i-1; m++){
if (*p+m>*p+m+1){
n=*(p+m);
*(p+m+1)=*(p+m);
*(p+m)=n;
}
}
}
return *p;
}
void print(int num[], int x)
{
int cnt;
for(cnt=0; cnt<x; cnt++)
printf ("%d", num[cnt]);
}
int main()
{
int i, x, y, z, m, n;
printf ("请输入两组数组的长度：");
scanf ("%d %d", &x, &y);
z=x+y;
int num1[x],num2[y],num3[z];
printf ("请输入第一组数组中的数：");
for (i=0; i<x; i++){
scanf ("%d", &num1[i]);
num3[i]=num1[i];
}
printf ("请输入第二组数组中的数：");
for (i=0; i<x; i++){
scanf ("%d", &num2[i]);
num3[x+i]=num2[i];
}
sort (num1[x], x);
sort (num2[y], y);
sort (num3[z], z);
print (num1[x], x);
print (num2[y], y);
print (num3[z], z);
return 0;
}
``````

2个回答

``````#include <stdio.h>
#define MAX 100
void sort(int *p, int x)
{
int m, n, i;
for (i=0; i<x-1; i++){
for (m=0; m<x-i-1; m++){
if (*(p+m)>*(p+m+1)){
n=*(p+m + 1);
*(p+m+1)=*(p+m);
*(p+m)=n;
}
}
}
}
void print(int num[], int x)
{
int cnt;
for(cnt=0; cnt<x; cnt++)
printf ("%d ", num[cnt]);
printf("\n");
}
int main()
{
int i, x, y, z, m, n;
printf ("请输入两组数组的长度：");
scanf ("%d %d", &x, &y);
z=x+y;
int num1[MAX],num2[MAX],num3[MAX+MAX];
printf ("请输入第一组数组中的数：");
for (i=0; i<x; i++){
scanf ("%d", &num1[i]);
num3[i]=num1[i];
}
printf ("请输入第二组数组中的数：");
for (i=0; i<y; i++){
scanf ("%d", &num2[i]);
num3[x+i]=num2[i];
}
sort (num1, x);
sort (num2, y);
sort (num3, z);
print (num1, x);
print (num2, y);
print (num3, z);
return 0;
}

``````

1 5 9
0 1 2 9
0 1 1 2 5 9 9
Press any key to continue . . .

# 问题解决的话，请点下采纳

C__zhazha 多谢啦！
3 个月之前 回复

int num1[x],num2[y],num3[z];

int num1[100],num2[100],num3[200];

C__zhazha 多谢啦！
3 个月之前 回复