Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class EqualSumsEvenOddPosition {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int startNum = Integer.parseInt(scanner.nextLine()),
- endNum = Integer.parseInt(scanner.nextLine());
- for (int i = startNum; i <= endNum; i++) {
- int odd = 0, even = 0, digit = i;
- for (int x = 0; x < 6; x++) {
- if (x % 2 == 0) {
- even += digit % 10;
- } else {
- odd += digit % 10;
- }
- digit /= 10;
- }
- if (odd == even) {
- System.out.printf("%d ",i);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement