Pls help me, i don't understand where is the error, as the server doesn't pass my code:
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int maximum = Integer.MIN_VALUE;
String qq = reader.readLine();
int n = Integer.parseInt(qq);
for(int i=0; i<n; i++){
String rr = reader.readLine();
int ww = Integer.parseInt(rr);
if (ww <= 0){
break;
} else if(maximum < ww){
maximum = ww;
}
}
//write your code here
if(maximum > 0)
System.out.println(maximum);
}
}
pls help me
Under discussion
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
hidden #10513713
5 February 2020, 17:54
Everything runs fine until the conditional within the "for" loop. I used one conditional. Then if that condition evaluated to 'true' I updated the variable "maximum". Then I printed "maximum" to the console outside the "for" loop code block.
0
hidden #10513713
5 February 2020, 13:34
Which requirement is not passing? All of them?
0
max
4 February 2020, 10:30
added to the code following statement, befor for cicle:
if (n>0){
for .....
but still not passed the verification :-(
0
Anthony Chalk
2 February 2020, 14:41
only n has to be greater than 0.
The next n numbers read from the keyboard don't have to
0