galinyotsev123

ProgBasics07Nested-Loops-Y11specialNumbers

Jan 9th, 2019
72
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.  
  3. public class Y11specialNumbers {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Scanner sc = new Scanner(System.in);
  8.  
  9. int n = Integer.parseInt(sc.nextLine());
  10.  
  11. int resto = 0;
  12.  
  13. for (int i = 1111; i <= 9999; i++) { // DCBA
  14.  
  15. int a = i % 10;
  16. resto = i / 10; // DCB
  17.  
  18. int b = resto % 10;
  19. resto = resto / 10; // DC
  20.  
  21. int c = resto % 10;
  22. resto = resto / 10; //D
  23.  
  24. int d = resto;
  25.  
  26. if (a != 0 && b != 0 && c != 0 ) { // prowerqwame dali
  27. // sa razlichni ot nula , D nqma kak da e nula, zashotot chislata sa 4 cifreni
  28. if (n % a == 0 && n % b == 0 && n % c == 0 && n % d == 0) { // prowerka che se
  29. // deli bez ostatyk N na vsqka cifra
  30.  
  31. System.out.print(d + "" + c + "" + b + "" + a + " ");
  32. }
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment