Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Operacje.h"
- #include <stdlib.h>
- #include <iostream>
- using namespace std;
- struct STRUKTURA
- {
- double double1;
- double double2;
- double double3;
- int liczba;
- struct STRUKTURA* nast;
- struct STRUKTURA* wcze;
- };
- void Operacje::inicjacja() {
- struct STRUKTURA* strukura;
- strukura = (struct STRUKTURA*)malloc(sizeof(struct STRUKTURA));
- strukura->nast = NULL;
- Operacje::struktura = strukura;
- }
- struct STRUKTURA* Operacje::adres() {
- return Operacje::struktura;
- }
- void Operacje::dodajElement(int element) {
- struct STRUKTURA* tmp = Operacje::struktura;
- struct STRUKTURA* tmp2;
- if (Operacje::struktura->nast == NULL)
- {
- tmp->double1 = 1;
- tmp->double2 = 1;
- tmp->double3 = 1;
- tmp->liczba = element;
- tmp->nast = tmp;
- tmp->wcze = tmp;
- }
- else {
- struct STRUKTURA* nowy;
- nowy = (struct STRUKTURA*)malloc(sizeof(struct STRUKTURA));
- do
- {
- if (tmp == Operacje::struktura) {
- nowy->double1 = (rand() % 100);
- nowy->double2 = (rand() % 1000) + 101;
- nowy->double3 = (rand() % 10000) + 1001;
- nowy->liczba = element;
- nowy->nast = Operacje::struktura;
- nowy->wcze = tmp;
- tmp->nast = nowy;
- Operacje::struktura->wcze = nowy;
- }
- tmp = tmp->nast;
- } while (tmp != Operacje::struktura);
- }
- }
- void Operacje::wyswietlElementy() {
- struct STRUKTURA* tmp = Operacje::struktura;
- do
- {
- cout << tmp->liczba;
- tmp = tmp->nast;
- if (tmp == Operacje::struktura)
- break;
- } while (tmp != tmp->nast);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement