Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class EqualSums {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String[] input = scanner.nextLine().split(" ");
- int[] numbers = new int[input.length];
- for (int i = 0; i < numbers.length; i++) {
- numbers[i] = Integer.parseInt(input[i]);
- }
- for (int i = 0; i < numbers.length; i++) {
- int leftSum = 0;
- for (int j = 0; j < i; j++) {
- leftSum += numbers[j];
- }
- int rightSum = 0;
- for (int j = i + 1; j < numbers.length; j++) {
- rightSum += numbers[j];
- }
- if (leftSum == rightSum) {
- System.out.println(i);
- return;
- }
- }
- System.out.println("no");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement