package exam;
 import java.io.*;
public class t03 {
  public static void main(String args[]) throws Exception {
   BufferedReader fr = new BufferedReader(new FileReader("data03.txt"));

   String name = "李依靜", num = "4020Q090";
   int i = 0, j = 0, k = 0;
   int A[][] = new int[3][3], B[][] = new int[3][3], C[][] = new int[3][3];

   System.out.println("學號:" + name + "\t" + "姓名:" + num);

   for (j = 0; j < A.length; j++) {
    for (i = 0; i < A[j].length; i++) {
     A[j][i] = Integer.parseInt(fr.readLine());
     System.out.print(A[j][i] + "\t");
    }
    System.out.println();
   }
   for (j = 0; j < A.length; j++) {
    for (i = 0; i < B[j].length; i++) {
     B[j][i] = Integer.parseInt(fr.readLine());
     System.out.print(B[j][i] + "\t");
    }
    System.out.println();

   }


   for (j = 0; j < B[0].length; j++) {
    for (k = 0; k < A.length; k++) {
     for (i = 0; i < A[0].length; i++) {
      C[j][k] = C[j][k] + A[j][i] * B[i][k];
     }

     System.out.print(C[j][k] + "\t");
    }
    System.out.println();
   }
  }
 }

 

arrow
arrow
    全站熱搜

    玥君 發表在 痞客邦 留言(0) 人氣()