5. Calculate the maximum number.
Time Limit: 1000 MS | memory limit: 65535 KB
Difficulty: 1
Description
Design a program for getting the minimum and maximum numbers from five Integers
Input
The input contains only one set of test data, which is five positive integers not greater than 10 thousand.
Output
Output two numbers. The first is the minimum value of the five numbers, the second is the maximum value of the five numbers, and the two numbers are open in an empty space.
Sample Input
1 2 3 4 5 sample output
1 5
# Include <iostream>
Using namespace STD;
Int main ()
{
Int I, Max, Min, a [5];
For (I = 0; I <5; I ++)
Cin> A [I];
Max = min = A [0];
For (I = 0; I <5; I ++)
{
If (A [I]> MAX) max = A [I];
If (A [I] <min) min = A [I];
}
Cout <min <"" <max <Endl;
}
***************
# Include <stdio. h>
Int main ()
{
Int A, Max, Min, I;
Scanf ("% d", & );
Max = min =;
For (I = 1; I <= 5; I ++)
{
Scanf ("% d", & );
If (A <min)
{Min = ;}
If (A> MAX)
{Max = ;}
Printf ("% d \ n % d", Min, max );
Return 0;
}
}
*****************
*************************************
# Include <stdio. h>
Int main ()
{
Int A [5], I, Max, min;
For (I = 0; I <5; I ++)
{
Scanf ("% d", & A [I]);
}
Max = min = A [0];
For (I = 1; I <5; I ++)
{
If (A [I] <min)
Min = A [I];
}
Printf ("% d", min );
For (I = 1; I <5; I ++)
{
If (A [I]> MAX)
Max = A [I];
}
Printf ("% 2D", max );
Return 0;
}
**************************
# Include <iostream>
Using namespace STD;
Int main ()
{
Int A = 5;
Int I, n [5], T;
For (I = 0; I <5; I ++)
Cin> N [I];
Cout <Endl;
While (--)
{
For (I = 0; I <A; I ++)
{
If (N [I]> N [I + 1])
{T = N [I]; n [I] = N [I + 1]; n [I + 1] = T ;}
}
}
Cout <n [0] <"" <n [4] <Endl;
Return 0;
}
**********************************
# Include <stdio. h>
Int main ()
{
Int I, j, t, a [5];
Printf ("Enter five numbers smaller than 10 thousand :");
For (I = 0; I <5; I ++)
Scanf ("% d", & A [I]);
For (j = 0; j <4; j ++)
For (I = 0; I <4-j; I ++)
If (A [I] <A [I + 1])
{T = A [I + 1];
A [I + 1] = A [I];
A [I] = T;
}
Printf ("% d", a [4]);
Printf ("");
Printf ("% d \ n", a [0]);
Return 0;
}
**************************************** ********************
# Include <stdio. h>
Int main ()
{
Int Max, Min, A, I;
Scanf ("% d", & );
Max = min =;
For (I = 1; I <5; I ++)
{Scanf ("% d", & );
Max = (A> Max? A: Max );
Min = (a <min? A: min );
}
Printf ("% d", Min, max );
Return 0;
}
***********************************
# Include <iostream>
# Include <algorithm>
Using namespace STD;
Int main ()
{
Int A [5];
Cin> A [0]> A [1]> A [2]> A [3]> A [4];
Cout <* min_element (A, A + 5) <"" <* max_element (A, A + 5) <Endl;
Return 0;
}
*******************************
# Include <iostream>
# Include <algorithm>
Using namespace STD;
Int main ()
{
Int arr [30];
For (INT I = 0; I <5; I ++)
{
Cin> arr [I];
}
Sort (ARR, arr + 5 );
Cout <arr [0] <"" <arr [4] <Endl;
Return 0;
}