Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package LoopsInLoops_exercise;
- import java.util.Scanner;
- public class EqualSumsEvenOddPosition {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int num1= Integer.parseInt(scanner.nextLine());
- int num2= Integer.parseInt(scanner.nextLine());
- int sum1=0;
- int sum2=0;
- String first ;
- for (; num1 <=num2 ; num1++) {
- first= num1+"";
- for (int i = 1; i <=6 ; i++) {
- if(i%2==0){
- sum1+=Integer.parseInt((first.charAt(i-1)+""));
- }else{
- sum2+=Integer.parseInt((first.charAt(i-1)+""));
- }
- }
- if(sum1==sum2) System.out.print(num1+" ");
- sum1 =0;
- sum2 = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement