-
Notifications
You must be signed in to change notification settings - Fork 0
/
Macierz.cpp
52 lines (42 loc) · 874 Bytes
/
Macierz.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include "Macierz.h"
Macierz::Macierz(int wierzcholki)
{
ilosc_wierzch = wierzcholki;
macierz = new int*[wierzcholki];
for (int i = 0; i < wierzcholki; i++)
{
macierz[i] = new int[wierzcholki];
for (int j = 0; j < wierzcholki; j++)
{
macierz[i][j] = INT_MAX;
}
}
}
Macierz::~Macierz()
{
for (int i = 0; i < ilosc_wierzch; i++)
{
delete [] macierz[i];
}
delete [] macierz;
}
void Macierz::dodaj_k(int od_wierz, int do_wierz, int waga)
{
macierz[od_wierz][do_wierz] = waga;
}
int Macierz::pobierz_wage(int od_wierz, int do_wierz)
{
return macierz[od_wierz][do_wierz];
}
void Macierz::wyswietl()
{
for (int i = 0; i < ilosc_wierzch; i++)
{
for (int j = 0; j < ilosc_wierzch; j++)
{
std::cout << macierz[i][j] << " ";
}
std::cout << std::endl;
}
}