A problem of arranging the elements in an array in ascending order in language?

Updated on technology 2024-02-28
6 answers
  1. Anonymous users2024-02-06

    Summary. You can put the elements of both arrays into one array and then use the sort() function.

    C Array combines an ascending array and an array in descending order into one of the arrays.

    You can put the elements of both arrays into one array and then use the sort() function.

    You can follow your steps.

  2. Anonymous users2024-02-05

    8. i=9;

    9. a[i] >x

    10. a[i+1] = x

    For 8, the first copy needs to find the end of the array, so that bai can find it from back to front. For 9, we need to find the position where the x input zhi is greater than the number of dao in the array, so if the current array element is greater than x, we need to look forward.

    For 10, fill in the program according to the comments.

    Here are the results:

  3. Anonymous users2024-02-04

    This kind of operation of arrays is difficult and inefficient, and this situation is now handled by containers in STL (standard template library): vector, deque, list, map, etc.

  4. Anonymous users2024-02-03

    It is better to have the original question.

    The array you said above is 12345, enter 6, naturally it is in the last place, this is very easy to implement but if you enter 3, does this mean that this array does not change, or 12345?

    If you enter 7, 123457?

    But if the original data is not regular.

    How to design the original rules?

  5. Anonymous users2024-02-02

    #include

    Sort function. void sort(int a,int n)if(max!=i)}}

    int main()

    sort(a,10);

    a is an array that needs to be sorted, and there are 10 of them.

    for(i=0;i<10;i++)

    printf("%d, ",a[i]);The case before insertion printf("");

    scanf("%d",&a[10]);

    sort(a,11);

    for(i=0;i<11;i++)

    printf("%d, ",a[i]);The case after inserting printf("");

    return 0;}

  6. Anonymous users2024-02-01

    The loop of inserting x is followed by a failed insertion, i.e. x is placed at the end of a new array (length n+1); Then try to insert y into this new array, and the number of loops is one more than the one on the shouting field (iImplementation**:

    #include

    using namespace std;

    int main()

    int n, i, j;

    int a[20];

    int x, y;

    cin >>n;

    for (i = 0; i < n; i++)

    cin >>a[i];

    cin >>x >>y;

    for (i = 0; i < n;i++) try to insert x into the original array of silver infiltration of length n.

    if (a[i] >x)

    for (j = n; j > i; j--)

    a[j] =a[j - 1];

    a[i] =x;

    break;

    if (i ==n) puts it at the end a[n] if x can't insert an array.

    a[i] =x;

    for (i = 0; i < n + 1;i++) attempts to insert y into an array of length n+1 with x.

    if (a[i] >y)

    for (j = n + 1; j > i; j--)

    a[j] =a[j - 1];

    a[i] =y;

    break;

    if (i ==n+1) puts it at the end a[n+1] if y can't insert an array.

    a[i] =y;

    for (i = 0; i < n + 2; i++)

    cout

Related questions
8 answers2024-02-28

It's nonsense to say so much above. Landlord please see: pay attention to your program: printf("%d,%d",(a,b),(b,a); >>>More

43 answers2024-02-28

There are two easiest ways to transfer one character's gold to another in the same account: >>>More

14 answers2024-02-28

function assoc_unique($arr, $key) {

tmp_arr = array(); >>>More

6 answers2024-02-28

It will affect if it is not handled well, and it will have a big impact, and a program like yours has changed everything, and the IP has changed, which is equivalent to a big change. >>>More