import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in =new Scanner (System.in); int n = in.nextInt(); in.nextLine(); //代替C++的getchar(). while(n-->0) { String a; a=in.nextLine(); System.out.println(a); } } }
getchar()和scanf("%c")的功能都是从STDIN读一个字符,单论功能两者没有区别. 但两者的返回值是有区别的: ------------------------------------------------ scanf()的详尽介绍请移步这里. ------------------------------------------------- scanf()的返回值的含义是: On success, the function returns the number of