I want to share how to display 10
integer and summation. You can use this code but if you copy this code and
paste in your blog/website, please insert this link of article.
------
/** IsiMatrix.java
*
* Created on November 8, 2008, 9:56 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package matrix;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author amikom
*/
public class IsiMatrix {
/** Creates a new instance of IsiMatrix */
public IsiMatrix() {
}
public static void main(String[] args)throws IOException {
int[][] matrix1=new int[3][3];
int[][]matrix2={{1,7,3},{4,10,6},{7,80,99}};
BufferedReader bf=new BufferedReader(
new InputStreamReader(System.in));
//mengisikan nilai matrix
for(int b=0;b<3 b="" br=""> for(int k=0;k<3 br="" k=""> System.out.println("Masukkan matrix[" + b + "][" + k +"]");
matrix1[b][k]=Integer.parseInt(bf.readLine());
}
}
//menampilkan isi matrix1
for(int b=0;b<3 b="" br=""> for(int k=0;k<3 br="" k=""> System.out.print(matrix1[b][k] + "\t");
}
System.out.print("\n");
}
//menampilkan isi matrix2
for(int b=0;b<3 b="" br=""> for(int k=0;k<3 br="" k=""> System.out.print(matrix2[b][k] + "\t");
}
System.out.print("\n");
}
}
}3>3>3>3>3>3>
0 komentar:
Posting Komentar