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 maximum = 0;
int N = 2;
while (N > 0) {
int a = Integer.parseInt(reader.readLine());
int b = Integer.parseInt(reader.readLine());
N = N - 2;
if(a < b) {
maximum = b;
} else {
maximum = a;
}
}
System.out.println(maximum);
}
}
Karolina
Level 7
Done, Thanks :D
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Karolina
5 June 2020, 17:09
Thank You!
0
Tony Roy
5 June 2020, 17:04solution
Read N from the keyboard. Then if N > 0, in a loop read numbers from the keyboard, always keeping the largest of all the numbers read so far. (You cannot simply start with max = 0, since the largest might be negative.)
PS If you push the help button from the task, you will see that many other people have had questions on this task -- and you can often gather an answer from such discussions. (I would have been dead without this.)
+2