题解 | 单组_二维字符数组

单组_二维字符数组

https://www.nowcoder.com/practice/2316c1fedff14a8d91694a26c9da3310

import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        short n = in.nextShort();
        short m = in.nextShort();
        String o = in.nextLine();
        String[] reversedArr = new String[n];
        // 从倒数第一行开始
        for(short i = (short)(n - 1); i >= 0; i--){
            String s = in.nextLine();
            StringBuilder reversed = new StringBuilder();
            // 从倒数第一位开始
            for(short j = (short)(m - 1); j >= 0; j--){
                reversed.append(s.charAt(j));
            }
            // 3 2 1  3 1 1  3 0 1
            reversedArr[i] = reversed.toString();
        }
        for(String line:reversedArr)
        System.out.println(line.toString());
            
        in.close();
    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
03-26 22:55
门头沟学院 Java
烤冷面在迎接:河南byd,应该就是郑大了。不过24届计算机是特殊情况,那年除了九✌和强2,以及两三个关系够硬的双非,其他的都是炮灰,感觉是十几年来互联网行业最烂的一年,如果想了解最新的就业情况,得找现在的大四。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务