SHARE
TWEET

Untitled

a guest Oct 21st, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. typedef struct ell {
  3.     int klucz;
  4.     struct ell *nast;
  5. } el;
  6.  
  7. typedef el *wel;
  8. using namespace std;
  9. //q - znaleziony element
  10. //nowy_klucz - wartosc ktora chcemy umiescic przed/za znalezionym elementem
  11.  
  12. void dodajza (wel q, int nowy_klucz){
  13.     wel nowy_element = new el;
  14.     if(nowy_element == NULL){
  15.         cout << "nie udalo sie.";
  16.         return;
  17.     }
  18.     nowy_element -> klucz = nowy_klucz;
  19.     nowy_element -> nast = q -> nast;
  20.     q -> nast = nowy_element;
  21. }
  22.  
  23. void dodajprzed (wel q, int nowy_klucz){
  24.     wel nowy_element = (wel)malloc(sizeof(el));
  25.     if(nowy_element != NULL){
  26.         nowy_element -> klucz = q -> klucz;
  27.         nowy_element -> nast = q -> nast;
  28.         q -> nast = nowy_element;
  29.         q -> klucz = nowy_klucz;
  30.     }
  31. }
  32.  
  33. //co trzeba zrobić? takie funkcje:
  34.  
  35. void dodajprzed(wel *r, int klucz){
  36.    wel nowy_element = new el;
  37.    if(nowy_element == NULL){
  38.        cout << "nie udalo sie.";
  39.        return;
  40.    }
  41.    nowy_element -> klucz = klucz;
  42.    nowy_element -> nast = (*r) -> nast;
  43.    (*r) -> nast = nowy_element;
  44.  
  45. }
  46.  
  47. void dodajza(wel *r, int klucz){
  48.     wel nowy_element = (wel)malloc(sizeof(el));
  49.     if(nowy_element != NULL){
  50.         nowy_element -> klucz = (*r) -> klucz;
  51.         nowy_element -> nast = (*r) -> nast;
  52.         (*r) -> nast = nowy_element;
  53.         (*r) -> klucz = klucz;
  54.     }
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top