Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int[] numbers = Arrays
- .stream(scanner.nextLine().split(" "))
- .mapToInt(Integer::parseInt)
- .toArray();
- boolean isFound = false;
- for (int i = 0; i < numbers.length; i++) {
- int rightSum = 0, leftSum = 0;
- for (int r = i + 1; r < numbers.length; r++) {
- rightSum += numbers[r];
- }
- for (int l = i - 1; l >= 0; l--) {
- leftSum += numbers[l];
- }
- if (rightSum == leftSum) {
- System.out.println(i);
- isFound = true;
- break;
- }
- }
- if (!isFound) {
- System.out.println("no");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement