Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int m = Integer.parseInt(scanner.nextLine());
- for (int i = n; i <= m; i++) {
- int oddSum = 0;
- int evenSum = 0;
- String currentNum = "" + i; // текущото число го записвам в String
- for (int j = 0; j < 6; j++) {
- if (j % 2 == 0) {
- evenSum += currentNum.charAt(j); // на currentNum ми вземи позиция j
- } else {
- oddSum += currentNum.charAt(j);
- }
- }
- if (oddSum == evenSum) {
- System.out.print(i + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment