Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Using C language to exchange elements between two one-dimensional arrays
Using C language to exchange elements between two one-dimensional arrays
# include & ltstdio.h & gt

# Define N 5

void main()

{

int a[N],b[N],c;

int I;

Printf ("Please enter an array element: \ n");

for(I = 0; I & ltn;; i++)

scanf("%d ",& ampa[I]);

Printf ("Please enter a B array element: \ n");

for(I = 0; I & ltn;; i++)

scanf("%d ",& ampb[I]);

Printf ("The array elements after exchange are: \ n");

for(I = 0; I & ltn;; i++)

{

c = a[I];

a[I]= b[I];

b[I]= c;

}

for(I = 0; I & ltn;; i++)

printf("%3d ",a[I]);

printf(" \ n ");

for(I = 0; I & ltn;; i++)

printf("%3d ",b[I]);

printf(" \ n ");

}

//If you don't know, you can continue to ask.