in my mind if a number smaller than 0 was entered, the variable b would increase,
in the final case if the variable b had increased then a number smaller than or equal to 0 was inserted and therefore it did not have to print anything
currently, however, I only find number 6 printed and not the maximum
I know, it's a circle of things, but I couldn't think of anything else
package com.codegym.task.task05.task0532;
import java.io.*;
/*
Task about algorithms
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(reader.readLine());
int b=0;
int maximum = 0;
for(int i=0; i<N; i++){
int a = Integer.parseInt(reader.readLine());
if(a>0){
if(a>maximum){
maximum=a;
}
else{
maximum=maximum;;
}
}
else{
b=b+1;
break;
}
}
if(b>0){
System.out.println("");
}
else{
System.out.println(maximum);
}
//PARTE FINALE
}
}