Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Kneel down! A c language answer! Urgent need! Enter a one-dimensional integer array and find out the maximum and minimum values in the array elements and their corresponding subscripts!
Kneel down! A c language answer! Urgent need! Enter a one-dimensional integer array and find out the maximum and minimum values in the array elements and their corresponding subscripts!
Answer:

# include & ltstdio.h & gt

int main()

{

int num[ 10] = { 1,2,3,4,5,6,7,8,9, 10 };

int max = num[0],index _ max = 0;

int min = num[0],index _ min = 0;

int I = 0;

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

{

if(num[I]& gt; Max)

{

max = num[I];

index _ max = I;

}

}

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

{

if(num[I]& lt; Minimum)

{

min = num[I];

index _ min = I;

}

}

printf("max = %d,min =? %d”,num[index_max],num[index _ min]);

Returns 0;

}

Analysis:

The title requires finding two values and their subscripts, so we can set four variables.

Then compare it with the for loop (the basic knowledge of C language) and get the answer.

C language is a general computer programming language, which is widely used in the bottom development. The design goal of C language is to provide a programming language that can compile and process low-level memory in a simple way, generate a small amount of machine code and run without any support of running environment.

Although C language provides many low-level processing functions, it still maintains good cross-platform characteristics. C language programs written in standard specifications can be compiled on many computer platforms, even including some embedded processors (single chip microcomputer or MCU) and supercomputers.