Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Write a program to generate and print all symmetric numbers in given range [start…end] (0 ≤ start ≤ end ≤ 999). A number is symmetric if its digits are symmetric toward its middle. For example, the numbers 101, 33, 989 and 5 are symmetric, but 102, 34 and 997 are not symmetric.
- import java.util.Scanner;*/
- public class _01_SymmetricNumbersInRange {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int start = input.nextInt();
- int end = input.nextInt();
- for (int i = start; i <= end; i++) {
- if (i > 0 && i < 10) {
- System.out.println(i);
- }
- else {
- if (i%10 == i/10 || i%10 == i/100) {
- System.out.println(i);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment