#include <stdio.h>
#include <time.h>
void fun1(int *a, int n){
int i;
for (i=0;i<n;i++) a[i]=10+rand()%90;
}
void fun2(int *b, int n){
int i,j,t;
for (i=0;i<n-1;i++) for (j=i+1;j<n;j++)
if (b[i]>b[j]){t=b[i];b[i]=b[j];b[j]=t;}
}
int main()
{
int a[10],b[10],i,n=0;
srand(time(0));
fun1(a,10);
for (i=0;i<10;i++) printf ("%d ",a[i]); printf("\n");
for (i=0;i<10;i++) if (a[i]%2==0){b[n]=a[i];n++;};
fun2(b,n);
for (i=0;i<n;i++) printf ("%d ",b[i]);
return 0;
}
温馨提示:内容为网友见解,仅供参考