Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Random;
- import java.util.Scanner;
- public class FindElementIndex
- {
- public static void main(String[] args)
- {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Vyvedi chislo");
- int inputNum = scanner.nextInt();
- int[] arr = {5, 7, 3};
- while (true) {
- int printed = -1;
- for (int i = 0; i < arr.length; i++) {
- if (arr[i] == inputNum) {
- printed = i;
- break;
- }
- }
- System.out.println(printed);
- System.out.println("Vyvedi chislo");
- inputNum = scanner.nextInt();
- }
- }
- }
Add Comment
Please, Sign In to add comment