Given n number, find out the n number of maximum, minimum, and,
Input format
The first act integer n, saying the number of number of
The second line have n number for the given number n, the number of each absolute value is less than 10000,
The output format
Output three rows, each row an integer, the highest value in the first line says the number, the second line indicates the number of the minimum value in the third line indicates the number of these and,
The sample input
5
1, 3-2, 4, 5
Sample output
5
- 2
11.
The data size and agreed
1 & lt;=n & lt;=10000,
Here is my code:
Package JiChu;
import java.util.Scanner;
Public class basic4 {
Public static void main (String [] args) {
Scanner scan=new Scanner (System. In);
Int n=scan. NextInt ();
Int a=new int [] [n].//to hold the input values
//input number n
for(int i=0; iA [I]=scan. NextInt ();
}
Int sum=0, Max=a [0], min=a, [0].
for(int i=1; iIf (Max & lt; A [I]) {
Max=a, [I].
}
If (min & gt; A [I]) {
Min=a, [I].
}
sum +=a[i];
}
System. Out. Print (Max + "\ n" + min + + sum "\ n");
}
}
Running up the IDEA of do not have what problem, but always after submit 0,
The realization method of baidu other bosses mostly sort first, and then directly to get the Max and min, then cycle sum; Internet bloggers have a c + + and the ideas I wrote a MAO, I submitted his version of the c + +, 100 points, why Java is 0 points, bosses give small white labyrinth
CodePudding user response:
No hint what wrong or hints which set of test sample before?CodePudding user response:
Example according to the samples, please, "no problem" on the IDEA of running, the interface screenshots, .CodePudding user response:
Your output is correct, of course, 0
CodePudding user response:
for (int I=1; iIf (Max & lt; A [I]) {
Max=a, [I].
}
If (min & gt; A [I]) {
Min=a, [I].
}
sum +=a[i];
}
You I preliminary definition 1, starting from a [1] cycle to a [4], a [0] value add, combined get wrong
CodePudding user response:
Read your articles have to doubt you are fishing not look not to come out this