Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- struct complex {
- float re;
- float im;
- };
- struct data {
- int dzien;
- int miesiac;
- int rok;
- };
- struct dane {
- string nazwisko;
- string imie;
- struct data data_urodzenia;
- };
- complex suma(complex z1, complex z2) {
- struct complex z3;
- z3.re = z1.re + z2.re;
- z3.im = z1.im + z2.im;
- return z3;
- }
- complex roznica(complex z1, complex z2) {
- struct complex z3;
- z3.re = z1.re - z2.re;
- z3.im = z1.im - z2.im;
- return z3;
- }
- complex iloczyn(complex z1, complex z2) {
- struct complex z3;
- z3.re = z1.re * z2.re - z2.im * z2.im;
- z3.im = z1.re * z2.im * z2.im;
- return z3;
- }
- complex iloraz(complex z1, complex z2) {
- struct complex z3;
- z3.re = (z1.re*z2.re+z2.im*z2.im) / (z2.re*z2.re+z2.im*z2.im);
- z3.im = (z1.re*z2.re-z1.im*z2.im) / (z2.re*z2.re+z2.im*z2.im);
- return z3;
- }
- typedef complex(*Dupa)(complex, complex);
- Dupa tablica_funkcji_mat[4] = {suma, iloczyn, iloraz, roznica};
- complex wynik, a,b;
- wynik = tablica_funkcji_mat[1](a,b);
- wynik = iloczyn(a,b);
- void zespolone() {
- struct complex z1,z2,z3;
- for (int i = 0; i < 10; i++) {
- cout << i << "# Podaj z1 R:";
- cin >> z1.re;
- cout << "Podaj z1 U:";
- cin >> z1.im;
- cout << "# Podaj z2 R:";
- cin >> z2.re;
- cout << "Podaj z2 U:";
- cin >> z2.im;
- int zadanie;
- cout << endl << ":Podaj nr zadania: 1 + | 2 - | 3 * | 4 /";
- cin >> zadanie;
- switch (zadanie) {
- case 1:
- suma(z1,z2,z3);
- break;
- case 2:
- roznica(z1,z2,z3);
- break;
- case 3:
- iloczyn(z1,z2,z3);
- break;
- case 4:
- iloraz(z1,z2,z3);
- break;
- default:
- cout << "Blad";
- }
- cout << endl << "Wynik: R:" << z3.re << " U:" << z3.im << endl;
- }
- }
- data dodajDate() {
- struct data nowa;
- cout << "Podaj dzien:";
- cin >> nowa.dzien;
- cout << "Podaj miesiac:";
- cin >> nowa.miesiac;
- cout << "Podaj rok:";
- cin >> nowa.rok;
- return nowa;
- }
- dane *dodajCzlowieka() {
- struct dane *nowy = new dane;
- cout << "# Podaj imie:";
- cin >> nowy->imie;
- cout << "Podaj nazwisko:";
- cin >> nowy->nazwisko;
- nowy->data_urodzenia = dodajDate();
- return nowy;
- }
- void stworzBaze(int ilosc, struct dane **&tab) {
- tab = new dane*[ilosc];
- for (int i = 0; i < ilosc; i++) {
- tab[i] = dodajCzlowieka();
- }
- }
- int main() {
- struct dane **baza;
- stworzBaze(3, baza);
- baza[0]->imie = "Trakakaka";
- baza[1]->imie = "Lalallalala";
- baza[2]->imie = "Omega WTF";
- cout << baza[0]->imie << " " << baza[1]->imie << " " << baza[2]->imie << " " << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment