¾ØÕóÁ¬³ËËã·¨javaʵÏÖ
public class MatrixChainOrder {
int[] p;
int[][] m;
int[][] s;
int length;
public MatrixChainOrder(int[] p,int[][] m,int[][] s){
this.p = p;
this.length = p.length/2;
this.m = m;
this.s = s;
init();
clac();
printM();
}
public void init(){
for (int i=0;i<length;i++){
m[i][i] = 0;
}
}
public void clac(){
for (int i=1;i<length;i++){
for (int j=0;j<length-i;j++){
int r = j+i;
int t = Integer.MAX_VALUE;
for (int k = j;k<r;k++){
int temp = m[j][k] + m[k+1][r] + p[j*2]*p[k*2+1]*p[r*2+1];
if (t > temp){
t = temp;
m[j][r] = temp;
}
}
}
}
}
public void printM(){
for (int i=0;i<length;i++){
for (int j=0;j<length;j++){
System.out.print(m[i][j]+ "\t");
}
System.out.println();
}
}
public static void main(String args[]){
int p[] = {30,35,35,15,15,5,5,10,10,20,20,25};
int length = 6;
int[][] m = new int[6][6];
int[][] s = new int[6][6];
new MatrixChainOrder(p,m,s);
}
}
³ÌÐòÔËÐеĽá¹ûÊÇ:
0 15750 7875 9375 11875 15125
0 0 2625 4375 7125 10500
0 0 0 750 2500 5375
0 0 0
Ïà¹ØÎĵµ£º
ÀàÐÍת»»×ܽ᣺
1.ÔÐÍÊý¾Ýbyte,short,int,long,float,double,char,boolean,СÀàÐÍÊý¾Ý¿ÉÒÔÖ±½Ó¸³¸ø´óÀàÐÍÊý¾ÝÀýÈç
int a=1;byte b=2;short c=3;float d=3;double e=4;char f='a';boolean g=true;long l=10;
c=b;
a=f;
d=a;
e=d;
byteÐÍÊý¾Ý²»ÄÜÖ±½Ó¸³¸øcharÐÍÊý¾Ý£¬ÒòΪbyte±íʾµÄÊÇ8λÓзûºÅÊý£¬¶øchar±íʾµ ......
Ò»¡¢JavaÔËÐÐʱµÄÁ½ÖÖºËÐÄ»úÖÆ
£¨1£©JavaÐéÄâ»ú£¨Java Virtual Machine£©
ÓÃÀ´´¦ÀíJavaÔ´Îļþ±àÒëºóµÄ×Ö½ÚÂ룬ÆÁ±Îµ×²ãÔËÐÐÆ½Ì¨µÄ²îÒ죬ʵÏÖ“Ò»´Î±àÒë£¬Ëæ´¦Ö´ÐД£¬¶øÇÒ²»Í¬µÄÔËÐÐÆ ......
µÚ8Õ ¶àÏß³Ì
(Ò»)¿Î³ÌÄÚÈÝ
8.1Ï̵߳Ļù±¾¸ÅÄî
8.1.1Ï̵߳ÄÉúÃüÖÜÆÚ
8.1.2Ï̵߳÷¶ÈÓëÓÅÏȼ¶
8.2 ThreadÀàºÍRunnable½Ó13
8.2.1 ThreadÀà
8.2.2 Runnable½Ó¿Ú
8.3Ï̻߳¥³âºÍͬ²½
8.3.1Ï̻߳¥³â
8.3.2Ïß³Ìͬ²½
(¶þ)ѧϰĿµÄÓëÒªÇó
±¾Õ½éÉܶàÏ̵߳ĸÅÄîºÍ±àд¶àÏ̳߳ÌÐòµÄ·½·¨£¬ÊµÏÖÏß³ÌÖ®¼äÏ໥ͨÐźÍͬ²½µÄ¼¼ ......
......