Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Zamka
- {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- int L, D, X;
- int N = 0;
- int M = 0;
- L = scan.nextInt();
- D = scan.nextInt();
- X = scan.nextInt();
- for (int i = L; i <= D; i++) {
- int sum = 0;
- int temp = i;
- while (temp > 0) {
- sum = sum + temp%10;
- temp = temp/10;
- }
- temp = i;
- while (sum == X) {
- if (N == 0) {
- N = temp;
- M = temp;
- } else {
- M = temp;
- }
- break;
- }
- }
- System.out.println(N);
- System.out.print(M);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement