首页 > 代码库 > 流程控制与数组

流程控制与数组

1.数组赋值练习:

int[] a ={1,2,3,4};
int[] b;
b=a;
b[2]=1025;
System.out.print("数组一");
for (int i = 0; i <b.length; i++) {
System.out.print(b[i]);
}
System.out.print(" ");
System.out.print("数组二");
for(int i=0;i<b.length;i++){
System.out.print(b[i]);

2.乘法口诀的编写:

int[][] a1=new int[10][10];//声明数组
for(int i=1;i<a1.length;i++){
for(int y=1;y<=i;y++){
a1[i][y]=i*y;
System.out.print(+i+"*"+y+"="+a1[i][y]+" ");
}
System.out.println(" ");
}

3.

流程控制与数组