Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 import java.util.*;
- 2 public class Problema {
- 3 public static void main(String[] args) {
- 4 Scanner scanner = new Scanner(System.in);
- 5 double[] numere;
- 6 int k;
- 7 int nrElemente = scanner.nextInt();
- 8 numere = new double[nrElemente];
- 9 for (int i=0;i<nrElemente;i++) {
- 10 numere[i] = scanner.nextDouble();
- 11 }
- 12 int elemPozitive = 0;
- 13 int indexMax = 0;
- 14 for (int i=0;i<nrElemente;i++) {
- 15
- 16 if (numere[i]>0) {
- 17 k = 0;
- 18 while(numere[i+k]>0) {
- 19 k++;
- 20 if (i+k==nrElemente)
- 21 break;
- 22 }
- 23
- 24 if (k > elemPozitive) {
- 25
- 26 elemPozitive = k;
- 27 indexMax = i;
- 28 }
- 29
- 30
- 31 }
- 32 }
- 33 if (elemPozitive == 0)
- 34 indexMax = -1;
- 35 System.out.println(indexMax);
- 36 System.out.println(elemPozitive);
- 37 }
- 38
- 39 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement