JAVA 多行输入,单行考查。
来源:百度知道 编辑:UC知道 时间:2024/06/01 20:31:54
最好是,每次输入几行可自己确定。
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
public class test {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
String b1 = b.readLine();
String b2 = b.readLine();
String b3 = b.readLine();
String b4 = b1+" "+b2+" "+b3;
String[] str =b4.split(" ");
Arrays.sort(str);
int j=str.length/3;
for(int i=0;i<str.length;i++){
System.out.print(str[i].toString()+" ");
if(i==j||i==j*2){
System.out.println("");
}
}
}