题解HJ11 | #数字颠倒#

数字颠倒

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

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str=in.nextLine();
        int[] myarray=new int[str.length()];
        //倒序
        for(int i =0;i<str.length();i++){
            myarray[i]=str.charAt(str.length()-i-1)-'0';
        }
        //输出
        for(int i=0;i<str.length();i++){
            System.out.print(myarray[i]);
        }
    }
}


直接以字符串的形式接受,然后倒序放到数组里,最后以数组按顺序输出即可,放到字符串里也一样,因为前面HJ9有做过一次颠倒,所以直接套用了,还省略了去重的步骤

#华为od题库#
全部评论

相关推荐

叁六玖:你看,最后不是让你加油,就是鼓励你,还祝福你求职顺利。
点赞 评论 收藏
分享
10-09 16:12
门头沟学院 Java
帅宇殿下:佬,简历写的什么
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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