Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Define a plastic array consisting of ten elements, input each element from the keyboard, and exchange the maximum value of the array with the first element, the minimum value and the last element.
Define a plastic array consisting of ten elements, input each element from the keyboard, and exchange the maximum value of the array with the first element, the minimum value and the last element.
# Including

empty

primary

()

{

Internationalorganizations (same as international organizations)

I

=

0;

Internationalorganizations (same as international organizations)

t

=

0;

Internationalorganizations (same as international organizations)

ss[ 10]

=

{0};

Internationalorganizations (same as international organizations)

nMaxIndex

=

0;

Internationalorganizations (same as international organizations)

nMinIndex

=

0;

//

Input data data

Printf ("Please enter 10 numbers separated by commas: \ n");

for

(I

=

0;

I

& lt

10;

i++)

scanf("%d ",

& ampss[I]);

//

An index that records the maximum and minimum values.

for

(I

=

1;

I

& lt

10;

i++)

{

if

(ss[i]

& gt

ss[nMaxIndex])

nMaxIndex

=

Me;

if

(ss[i]

& lt

ss[nMinIndex])

nMinIndex

=

Me;

}

//

Exchange the maximum value with array [0]

t

=

ss[0];

ss[0]

=

ss[nmax index];

Maximum index

=

t;

//

Exchange the minimum value with the array [9]. If the index of the minimum value happens to be the array [0], the index of the maximum value is exchanged.

if

(nMinIndex

==

0)

nMinIndex

=

nMaxIndex

t

=

ss[9];

Chapter 9

=

ss[nmin index];

Nanometer index

=

t;

for

(I

=

0;

I

& lt

10;

i++)

printf("%4d ",

ss[I]);

}

//

If other elements in the array can be exchanged, they are arranged in descending order.