You are viewing a single comment's thread. Return to all comments →
We can do directly in main function -
public static void main(String[] args) { int min_record = 0; int max_record = 0; int worst = 0; int best = 0; int curr_record = 0; Scanner in = new Scanner(System.in); int n = in.nextInt(); for(int s_i=0; s_i < n; s_i++){ curr_record = in.nextInt(); if(s_i == 0) { min_record = curr_record; max_record = curr_record; } if(s_i > 0) { if(curr_record < min_record) { min_record = curr_record; worst++; } else if (curr_record > max_record) { max_record = curr_record; best++; } } } System.out.println(best + " " + worst); System.out.println(""); in.close(); }
Seems like cookies are disabled on this browser, please enable them to open this website
Breaking the Records
You are viewing a single comment's thread. Return to all comments →
We can do directly in main function -