Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication3
- {
- public class Matrix
- {
- private static Random random = new Random();
- public static int[,] GenerateMatrix(int rows, int cols,int minRange = 0, int maxRange = 30)
- {
- var matrix = new int[rows, cols];
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- matrix[i, j] = random.Next(minRange, maxRange);
- }
- }
- //tutaj kod do generowania macierzy
- return matrix;
- }
- public static void DisplayMatrix(int[,] matrix)
- {
- //getlength 0 lub 1 - zwraca wartość długości kolumn (0) i wierszy (1)
- //getLuoweBound
- //Length - liczba wszytkich wlwmentów tablicy
- //tutaj kod od wyswietlania macierzy
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- Console.Write("{0}\t",matrix[i,j]);
- }
- Console.WriteLine();
- }
- }
- public static int[,] MultiplyMmatrices(int[,] tab1, int[,] tab2)
- {
- if (tab1.GetLength(1) != tab2.GetLength(0))
- {
- throw new ArgumentException("Liczba kolumn macierzy 1 musi byc równa liczbie wierszy macierzy 2.");
- }
- var result = new int[tab1.GetLength(1),tab2.GetLength(0)];
- for (int i = 0; i < tab1.GetLength(1); i++)
- {
- for (int j = 0; j < tab2.GetLength(0); j++)
- {
- for (int k = 0; k < tab1.GetLength(1); k++)
- {
- }
- }
- }
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement