java 实例,为每一行的输入自动编号

/*例如输入 SY
IN
输出:
1 SY
2 IN
*/
import
java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner scan=new Scanner(System.in); int n=1; while(scan.hasNext()) { String line = scan.nextLine(); System.out.println(n+" "+line); n++; } } }
原文地址:https://www.cnblogs.com/Angella/p/6523258.html