Advertisement
Guest User

1533

a guest
Apr 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Main {
  4.     public static void main(String[] Args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int n, a[], x;
  7.         while (true) {
  8.             n = scan.nextInt();
  9.             if (n == 0) {
  10.                 break;
  11.             }
  12.             a = new int[n]; x = 0;
  13.             for (int i = 0; i < n; i++) {
  14.                 a[i] = scan.nextInt();
  15.                 if (a[x] < a[i]) {
  16.                     x = i;
  17.                 }
  18.             }
  19.             a[x] = 0;
  20.             for (int i = 0; i < n; i++) {
  21.                 if (a[x] < a[i]) {
  22.                     x = i;
  23.                 }
  24.             }
  25.             System.out.println(x + 1);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement