monkeyslut45

Untitled

Nov 11th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7.  
  8.         System.out.println("Введите кол-во элементов массива");
  9.         int n; int j = 1;
  10.         n = in.nextInt();
  11.         int[] m = new int[n];
  12.  
  13.         for (int i = 0; i < n; i++) {
  14.             m[i] = in.nextInt();
  15.         }
  16.  
  17.         for (int i = 0; i < n; i++) {
  18.             if (m[i] >= 0) {
  19.                 System.out.println(j);
  20.                 System.out.println(m[i]);
  21.                 break;
  22.             }
  23.             j++;
  24.         }
  25.     }
  26. }
Add Comment
Please, Sign In to add comment