Advertisement
marking2112

NLEqualSumEvenOddPositions

Oct 23rd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EqualSumsEvenPositions {
  4. public static void main(String[] agrs) {
  5. Scanner scanner = new Scanner(System.in);
  6. int num1 = Integer.parseInt(scanner.nextLine());
  7. int num2 = Integer.parseInt(scanner.nextLine());
  8.  
  9.  
  10. for (int i = num1; i <= num2 ; i++) {
  11. int first = i / 100000;
  12. int second = (i / 10000) % 10;
  13. int third = (i / 1000) % 10;
  14. int forth = (i / 100) % 10;
  15. int fifth = (i / 10) % 10;
  16. int sixth = i % 10;
  17.  
  18. if(first + third + fifth == second + forth + sixth){
  19. System.out.print(i + " ");
  20. }
  21.  
  22.  
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement