Home > Back-end >  Write the C language program to enter two integer arrays, each array has five integers, and the corr
Write the C language program to enter two integer arrays, each array has five integers, and the corr

Time:09-17

For help! Write the C language program to enter two integer arrays, each array has five integers, and the corresponding position of the data and output in ascending order,

CodePudding user response:

A piece of code for reference, array input total write yourself
 
#include

Int main ()
{
Int arr1 [5]={10, 8, 16, 6, 23};
Int arr2 [5]={33, 45,12,79,11};
Int arr3 [5]={0};
Int I, j, temp.

for (i=0; i<5; I++)
{
Arr3 [I]=arr1 arr2 [I] + [I];
}

for (i=0; i<5; I++)
{
For (j=0; j<4 - I; J++)
{
If (arr3 [j] {
Temp=arr3 [j];
Arr3 [j]=arr3 [j + 1);
Arr3 [j + 1)=temp;
}
}
}

for (i=0; i<5; I++)
Printf (" % d ", arr3 [I]);
printf("\n");

getchar();
return 0;
}

CodePudding user response:

reference 1st floor CHXCHXKKK response:
a piece of code for reference, an array of input total write yourself
 
#include

Int main ()
{
Int arr1 [5]={10, 8, 16, 6, 23};
Int arr2 [5]={33, 45,12,79,11};
Int arr3 [5]={0};
Int I, j, temp.

for (i=0; i<5; I++)
{
Arr3 [I]=arr1 arr2 [I] + [I];
}

for (i=0; i<5; I++)
{
For (j=0; j<4 - I; J++)
{
If (arr3 [j] {
Temp=arr3 [j];
Arr3 [j]=arr3 [j + 1);
Arr3 [j + 1)=temp;
}
}
}

for (i=0; i<5; I++)
Printf (" % d ", arr3 [I]);
printf("\n");

getchar();
return 0;
}

Bosses some directions, really can't write

CodePudding user response:

The mutation of sorting, shrimp fresh stuff,
  • Related