Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- class LiczbaZespolona {
- private:
- double a;
- double b;
- public:
- LiczbaZespolona()
- {
- a = 1.0;
- b = 2.0;
- }
- LiczbaZespolona(double x, double y)
- {
- a = x;
- b = y;
- }
- ~LiczbaZespolona()
- {
- }
- friend bool porownaj(LiczbaZespolona, LiczbaZespolona);
- friend ostream& operator<<(ostream& os, const LiczbaZespolona& liczba);
- };
- ostream& operator<<(ostream& outstream, const LiczbaZespolona& liczba) {
- outstream << liczba.a << " " << liczba.b;
- return outstream;
- }
- template<class Typ>
- bool porownaj(Typ a, Typ b)
- {
- if (a == b)
- return true;
- else
- return false;
- }
- bool porownaj(LiczbaZespolona l1, LiczbaZespolona l2)
- {
- if ((l1.a == l2.a) && (l1.b == l2.b))
- return true;
- else
- return false;
- }
- template<class TypM> class Macierz
- {
- private:
- vector< vector< TypM > > macierz;
- int szerokosc;
- int wysokosc;
- public:
- Macierz()
- {
- szerokosc = wysokosc = 5;
- vector< vector< TypM > > tempMacierz(szerokosc, vector<TypM>(wysokosc, TypM()));
- macierz = tempMacierz;
- }
- Macierz(int x, int y)
- {
- szerokosc = x;
- wysokosc = y;
- vector< vector< TypM > > tempMacierz(szerokosc, vector<TypM>(wysokosc, TypM()));
- macierz = tempMacierz;
- }
- void Dodaj(TypM Element, int x, int y)
- {
- if (((x >= 0) && (x < szerokosc)) && ((y >= 0) && (y < wysokosc)))
- macierz[x][y] = Element;
- }
- TypM& Pobierz(int x, int y)
- {
- if (((x >= 0 )&& (x < szerokosc)) && ((y >= 0) && (y < wysokosc)))
- return macierz[x][y];
- }
- void Wypisz()
- {
- for (int i = 0; i < szerokosc; i++)
- {
- for (int j = 0; j < wysokosc; j++)
- cout << macierz[i][j] << " ";
- cout << endl;
- }
- }
- bool Porownaj(Macierz&)
- {
- }
- };
- int main()
- {
- Macierz<int> calkowite(9, 11);
- Macierz<double> zmiennoprzecinkowe(3, 7);
- Macierz<LiczbaZespolona> zespolone(8, 3);
- zespolone.Wypisz();
- int x; cin >> x;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement