题解 | #回文对称数#

回文对称数

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);
            }
        }
    }
}
全部评论

相关推荐

码农索隆:小同学,看看我查看图片
点赞 评论 收藏
分享
nbdy:字太多了,写简历不是写自传,亮点难点技能点列出来就行,要简明扼要
点赞 评论 收藏
分享
评论
3
1
分享

创作者周榜

更多
牛客网
牛客企业服务