Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Demo{
  3.  
  4.  
  5. static void Monkey(int n){
  6. for (int i = 10; i <n ; i++) {
  7. String MonkeyString = String.valueOf(i);
  8. String[] MonkeyArray = MonkeyString.split("");
  9. int[]MonkeyInt = new int[MonkeyArray.length];
  10. for (int j = 0; j <MonkeyArray.length ; j++) {
  11. MonkeyInt[j] = Integer.parseInt(MonkeyArray[j]);
  12.  
  13. }
  14. for (int j = 0; j <MonkeyInt.length-1 ; j++) {
  15. int sum;
  16. int first = MonkeyInt[j];
  17. int last = MonkeyInt[j+1];
  18. sum = first + last;
  19. if (first % 2 != 0 || last % 2 != 0)
  20. if (sum % 8 == 0) {
  21. System.out.println(i);
  22. }
  23. }
  24. }
  25. }
  26.  
  27. public static void main(String[] args) {
  28. Scanner scanner = new Scanner(System.in);
  29. int n = Integer.parseInt(scanner.nextLine());
  30. Monkey(n);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement