Advertisement
Dilyana86

Untitled

Apr 27th, 2017
672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class digits {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. int num = Integer.parseInt(scan.nextLine());
  7.  
  8. int numCopy = num;
  9. int digit3 = numCopy % 10;
  10. numCopy /= 10;
  11. int digit2 = numCopy % 10;
  12. numCopy /= 10;
  13. int digit1 = numCopy % 10;
  14.  
  15. for (int i = 0; i < digit1 + digit2; i++) {
  16. for (int j = 0; j < digit1 + digit3; j++) {
  17. if (num % 5 == 0) {
  18. num -= digit1;
  19. System.out.printf("%d ",num);
  20. }else if (num % 3 == 0) {
  21. num -= digit2;
  22. System.out.printf("%d ",num);
  23. }else {
  24. num += digit3;
  25. System.out.printf("%d ",num);
  26. }
  27. }
  28. System.out.println();
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement