题解 | #回文对称数#

回文对称数

http://www.nowcoder.com/practice/5b143af8328f4e42adf5e10397ae44ef

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            // 判断是否为回文数
            String s = String.valueOf(i);
            String result = "";
            for (int j = s.length() - 1; j >= 0; j--) {
                result += s.charAt(j);
            }
            if (result.equals(s)) {
                System.out.println(i);
            }
        }
    }
}
全部评论

相关推荐

2025-12-11 14:24
门头沟学院 Java
牛客35720396...:不要用boss,全是骗
点赞 评论 收藏
分享
想run的马里奥在学...:这个学历帮你扫平百分之80的障碍,投就完了,这会找不到就等3月暑期一样能找到
点赞 评论 收藏
分享
评论
4
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务