♠ Posted by Unknown at 7:37 AM
Latihan logika kali ini adalah array 3D..berbentuk kubus 10X10X10.... diputar diagonal sebesar 180 derjat dengan titik sumbu 1/2 sisi CG dan 1/2 AE. Sehingga sudut F menjadi sudut D...
Berikut hasilnya..// tapi masih bingung benar atau salah...
package c;
import java.util.Random;
/**
*
* @author Aan
*/
public class bj {
public static void main(String[] args) {
// TODO code application logic here
Random r=new Random();
int A[][][]=new int[10][10][10];
int aa=0,bb=0,cc=0;
for (int i = 0; i < A.length; i++) {
for (int j = 0; j < A.length; j++) {
for (int k = 0; k < A.length; k++) {
A[i][j][k]=r.nextInt(20)-10;
//System.out.print(r.nextInt(10)+" ");
}
}
//System.out.println();
}
System.out.println(A[0][0][9]);
int B[][][]=new int[10][10][10];
for (int i = 0; i < A.length; i++) {
for (int j = 0; j < A.length; j++) {
for (int k = 0; k < A.length; k++) {
B[k][j][i]=A[i][j][k];
}
}
//System.out.println();
}
System.out.println(B[9][9][9]);
aa=9;
for (int i = 0; i < A.length; i++) {
aa=9;
for (int j = 0; j < A.length; j++) {
for (int k = 0; k < A.length; k++) {
A[i][j][k]=B[i][aa][k];
}
aa--;
}
//System.out.println();
}
System.out.println(A[9][9][0]);
}
}
1 komentar:
Wa..bagus ne
Post a Comment