Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- public class Treasure {
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- final int SIZE = 50;
- int[] arr = new int[SIZE];
- // array needs to be initialized with correct order.
- int next = 0;
- int current = in.nextInt();
- while(next != -1)
- {
- next = arr[current];
- if(next == -1)
- break;
- arr[next] = current;
- }
- System.out.print(current);
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement