题解 | #字符逆序#

字符逆序

http://www.nowcoder.com/practice/cc57022cb4194697ac30bcb566aeb47b

import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String str = sc.nextLine();
            String  rts = "";
            for(int i = str.length()-1;i >= 0;i--){
                rts += str.substring(i,i+1);
            }
            System.out.println(rts);
        }
    }
}

倒序逐个截取字符即可

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 11:22
怎么这么多逆天求职者,救救我救救我救救我😭
flmz_Kk:哈哈哈哈哈哈,这么多求职者,肯定有那一两个逆天的
点赞 评论 收藏
分享
06-19 19:06
门头沟学院 Java
码农索隆:别去东软,真学不到东西,真事
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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