解题思路:
核心代码部分是运用了字符串切割的方法,对于前N的输入数据而言,仅需在while语句框内直接输出即可。配合“\n”的换行操作解题即可。
注意事项:
参考代码:
package com.dotcpp; import java.util.Scanner; public class 字符串的输入输出 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int N=sc.nextInt(); sc.nextLine(); while(sc.hasNext()) { while(N-->0) { System.out.println(sc.nextLine()+"\n"); } String s=sc.nextLine(); String parr[]=s.split(" "); for(int i=0;i<parr.length;i++) { System.out.println(parr[i]+"\n"); } } } }
0.0分
0 人评分