Sunday, May 1, 2016

URI Online Judge Solution 1080 Highest and Position

Main link : https://www.urionlinejudge.com.br/judge/en/problems/view/1080


URI Online Judge | 1080

Highest and Position

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read 100 integer numbers. Print the highest read value and the input position.

Input

The input file contains 100 distinct positive integer numbers.

Output

Print the highest number read and the input position of this value, according to the given example.
Input SampleOutput Sample
2
113
45
34565
6
...
8
34565
4


URI Online Judge Solution 1080 in Java

import java.io.IOException;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {
    int N =100, X, highest = 0,position = 0;
Scanner input =new Scanner(System.in);
for (int i = 1; i <= N; i++) {
X =input.nextInt();

if (highest > X) {
highest = highest;
position = position;
}else {
highest = X;
position = i;
}


}
System.out.print(highest+"\n"+position+"\n");
    }

}





No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.