九九乘法表如何准确对齐?
//九九乘法表
public class Chengfabiao
{
public static void main(String[] args)
{
for(int i=1;i <10;i++)
{
for(int j=1;j <10;j++)
{
if(i <j) break; System.out.print(i+ "* "+j+ "= "+(i*j
)+ " ");
}
System.out.println();
}
}
}
运行可以出现三角形的九九乘法表,但是结果中在3*3=9和4*3=12还有4*4和下面的排列不对齐,是不是写段程序,当做3*2,4*2,4*3时使后面的空格多空一格就可以了,象这样if((i=3&&j=2)||(i=4&&j=2)||(i=4&&j=3))
{
System.out.print(i+ "* "+j+ "= "+(i*j)+ " ");//这里空格长度是下面的两倍
}
运行出现错误 D:\MyJava> javac Chengfabiao.java
Chengfabiao.java:11: operator && cannot be applied to int,int
if((i=3&&j=2)||(i=4&&j=2)||(i=4&&j=3))
^
Chengfabiao.java:11: operator && cannot be applied to int,int
if((i=3&&j=2)||(i=4&&j=2)||(i=4&&j=3))
^
Chengfabiao.java:11: operator || cannot be applied to int,int
if((i=3&&j=2)||(i=4&&j=2)||(i=4&&j=3))
^
Chengfabiao.java:11: operator && cannot be applied to int,int
if((i=3&&j=2)||(i=4&&j=2)||(i=4&&j=3))