Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Zamka
  4. {
  5. public static void main(String[] args)
  6. {
  7. Scanner scan = new Scanner(System.in);
  8. int L, D, X;
  9. int N = 0;
  10. int M = 0;
  11. L = scan.nextInt();
  12. D = scan.nextInt();
  13. X = scan.nextInt();
  14. for (int i = L; i <= D; i++) {
  15. int sum = 0;
  16. int temp = i;
  17. while (temp > 0) {
  18. sum = sum + temp%10;
  19. temp = temp/10;
  20. }
  21. temp = i;
  22. while (sum == X) {
  23. if (N == 0) {
  24. N = temp;
  25. M = temp;
  26. } else {
  27. M = temp;
  28. }
  29. break;
  30. }
  31. }
  32. System.out.println(N);
  33. System.out.print(M);
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement