日期:2014-05-20 浏览次数:20778 次
int a[][] = new int[9][]; for(int i=0;i<9;i++){ a[i]=new int[i+1]; for(int j=0;j<a[i].length;j++){ a[i][j] = (i+1)*(j+1); System.out.print(a[i][j]+"\t"); } System.out.println(); }
------解决方案--------------------
给个例子给你参考一下:
public class MultiplicationTable { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub for (int i = 1; i < 10; i++) { for (int j = 1; j <= i; j++) { int multiplication = i * j; System.out.print(j + "*" + i + "=" + multiplication + "\t"); } System.out.println(); } } }
------解决方案--------------------
public class list { public static void main(String args[]) { //int a[][]=new int [100][100]; int sum = 0; for(int i=1;i <=9;i++) { for(int j=1;j <=i;j++) { //a[i][j]=i*j; //System.out.print("\t\t"+a[i][j]); sum=i*j; System.out.print(sum+" "); } System.out.println(); } } }
------解决方案--------------------
7楼的可以,其实就是两个for循环,搂主加油俄!