Advertisement
KechevD

KursovaRabota_SpecialNUms

Jan 13th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SpecialNUms {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int n = Integer.parseInt(scanner.nextLine());
  8. String num = "";
  9.  
  10. for (int i = 1; i < 9; i++) {
  11. for (int j = 1; j <9 ; j++) {
  12. for (int k = 1; k <9 ; k++) {
  13. for (int l = 1; l <9 ; l++) {
  14. num = ""+i+j+k+l;
  15. if (isSpecial(num,n)){
  16. System.out.print(num + " ");
  17. }
  18.  
  19. }
  20. }
  21. }
  22. }
  23. }
  24. public static boolean isSpecial(String num, int n){
  25.  
  26. boolean isSpecial = false;
  27.  
  28. for (int m = 0; m < num.length() ; m++) {
  29. char symbol = num.charAt(m);
  30. int number = Integer.parseInt(symbol+"");
  31. if (n % number == 0){
  32. isSpecial = true;
  33. }
  34. else {
  35. isSpecial = false;
  36. break;
  37. }
  38. }
  39.  
  40. return isSpecial;
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement