Advertisement
Hellman228

For Eugen

Jun 1st, 2020
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. public class Main {
  2.     public static void main(String[] args) {
  3.         double [] array = new double[10];
  4.         int first = 0,second = 0;
  5.         double sum = 0;
  6.         for(int i = 0; i<array.length; i++)
  7.         {
  8.             array[i] = Math.random()*20 - 10;
  9.             if(array[i] > 0 && first == 0){
  10.                 first = i;
  11.             }
  12.             else if(array[i] > 0 && first != i && second == 0){
  13.                 second = i;
  14.             }
  15.         }
  16.         for(int i = first; i< second; i++){
  17.             sum += array[i];
  18.         }
  19.         System.out.println(sum);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement