Skip to content

Instantly share code, notes, and snippets.

@JerzySpendel
Created October 11, 2015 16:35
Show Gist options
  • Save JerzySpendel/9615d8463c70c7c0af29 to your computer and use it in GitHub Desktop.
Save JerzySpendel/9615d8463c70c7c0af29 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
class CLista{
public:
struct punkt3D{
double x,y,z;
punkt3D *nastepny, *poprzedni;
};
CLista();
void dodajElement(double a, double b, double c);
void wstawElement();
void usunElement();
void wyszukajElement();
CLista::punkt3D* ostatniElement(punkt3D * pierwszy);
void wyswietlListe();
private:
punkt3D * pierwszy; //pierwszy element listy
punkt3D * ostatni; //ostatni element listy
int ile; //licznik elementow listy
};
CLista::CLista(){
pierwszy = ostatni = nullptr;
ile = 0;
}
void CLista::dodajElement(double a, double b, double c){
punkt3D * dodaj = new punkt3D; //utworzenie węzła (alokacja pamięci na nowy element)
dodaj->x = a;
dodaj->y = b;
dodaj->z = c;
dodaj->nastepny = nullptr;
ile++;
if (pierwszy == nullptr)
pierwszy = dodaj;
else{
punkt3D * ostatni = ostatniElement(pierwszy);
ostatni->nastepny = dodaj;
}
}
CLista::punkt3D* ostatniElement(CLista::punkt3D * pierwszy){
CLista::punkt3D * obecny = pierwszy;
do{
//makabra
} while(obecny!=nullptr);
return obecny;
}
int main(){
CLista lista;
lista.dodajElement(2, 3, 4);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment