本人审题不清,用了两个for循环,具体代码如下:
package ewanbao.mydomain.com;
public class NineMultiplyMatrix {
public static void main(String[] args) {
for (int i = 1; i <= 9; i++) {
int j = 1;
for( ; j <=i; j++) {
System.out.print(j + " * " + i + " = " + j*i + " ");
}
System.out.println();
}
}
}
源答案如下:
public void nineNineMulitTable(){
for (int i = 1,j = 1; j <= 9; i++) {
System.out.print(i+"*"+j+"="+i*j+" ");
if(i==j){
i=0;
j++;
System.out.println();
}
}
}