题解 | #数字颠倒#

数字颠倒

https://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {

        String s ="";
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            s = in.next();
        }

        result(s.toCharArray());
    }

    private static void result(char[] arr){
        int len = arr.length;
        for(int i=len-1;i>=0;i--){
            System.out.print(arr[i]);
        }
    }
}

和12题一样的思路

#努力刷题下#
雪域灰灰刷题笔记 文章被收录于专栏

雪域灰灰刷题笔记

全部评论

相关推荐

大世界中的渺小一棵:看出来你软硬都有基础,但是这样写简历软硬都擦边不知道你想投什么,建议针对岗位jd针对性修改下。
点赞 评论 收藏
分享
10-14 21:00
门头沟学院 Java
吃花椒的狸猫:这个人说的倒是实话,特别是小公司,一个实习生哪里来的那么多要求
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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