Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- class TriMatrix {
- private double myMat[][];
- private int n;
- TriMatrix ( int m) { //n - rozmiar macierzy
- double myMat[][] = new double[m][]; //zadeklarowanie ilości wierszy
- for(int i = 0; i< m; i++) {
- myMat[i]=new double[i+1]; //przydzielam pamięć dla poszczególnych wierszy
- }
- n = m;
- System.out.println("Utworzono macierz");
- }
- void fill() { //wypełnia macierz liczbami losowymi
- Random r= new Random();
- for(int i=0; i<n; i++) {
- for(int j=0; j<i+1; j++) {
- myMat[i][j]= r.nextDouble();
- }
- }
- System.out.println("Wypełniono macierz");
- }
- void print() {
- for(int i=0; i<n; i++) {
- for(int j=0; j<i+1; j++) {
- System.out.print(myMat[i][j] + " " );
- }
- System.out.println();
- }
- }
- }
Add Comment
Please, Sign In to add comment