DOC

import java

By Pauline Ferguson,2014-07-06 22:21
17 views 0
import java

import java.util.*;

     Random r = new Random();

     int N=5;

     int a[][]= new int[N][N];

     System.out.println("第一个矩阵;");

     for(int i=0;i

     for(int j=0;j

     a [i][j] = r.nextInt(10);

     }

     }

     for(int i=0;i

     for(int j=0;j

     System.out.print(a[i][j] + " ");

     }

     System.out.println();

     }

     int b[][]= new int[N][N];

     for(int i=0;i

     for(int j=0;j

     b[i][j] = r.nextInt(10);

     }

     }

     System.out.println("第二个矩阵;");

     for(int i=0;i

     for(int j=0;j

     System.out.print(b[i][j] + " ");

     }

     System.out.println();

     }

     int c[][]= new int[N][N];

     for(int i=0;i

     for(int j=0;j

     for(int k=0;k

     c[i][j]+=a[i][k]*b[k][j];

     }

     }

     }

     System.out.println("两个矩阵相乘;");

     for(int i=0;i

     for(int j=0;j

     System.out.print(c[i][j] + " ");

     }

     System.out.println();

}

}

}

Report this document

For any questions or suggestions please email
cust-service@docsford.com