java 实例,为每一行的输入自动编号
2017-03-08 21:48 backyyan 阅读(749) 评论(0) 编辑 收藏 举报/*例如输入 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++; } } }