Scanner sc1=new Scanner(System.in);
int m=sc1.nextInt();
Scanner sc2=new Scanner(System.in);
int n=sc2.nextInt();
1.如果写成这种,那么输入一行敲回车符,标志着读取一个数结束,如果用空格把两个数分开输入,是不行的。
Scanner sc1=new Scanner(System.in);
int m=sc1.nextInt();
int n=sc1.nextInt();
2.如果写成这种,则空格,回车都可以输入两个数字。
3.对于输出带有%的分数
System.out.printf("%.2f%% %.2f%%",a,b);
输出结果
0.40% 0.60%
当然这种表示小数是不正确的,需要在前面求值的时候乘100;就可以得到下面的答案
40.00% 60.00%
4.输出两个数中间用空格隔开。
System.out.print(a+" "+b);