Facebook
From ja, 4 Years ago, written in C++.
This paste is a reply to proszeniekrzyczana from ja - go back
Embed
 #include \n\nusing namespace std;\n\nstruct node{\nint val;
node* next;
};

void Add(node*&H, int x)
count(node*& H)
{
  node* p = new node;\n  p->val=x;\n  p->next=H;\n  H=p;\n}\nvoid del(node*&H)\n{\n  if(H!=NULL)\n  {\n    node*p = H;\n    H=H->next;\n    delete p;\n  }\n}\nvoid show(node*H)\n{\n  node*p=H;\n  while(p!=NULL)\n  {\n    cout<val<<"->";\n    p=p->next;\n  }\n  cout<<"NULL"<        node *p = H;
  while(p!=NULL)
  {
    if(p->val      {
      min=p->val;
    }
    p=p->next;
  }

  }
}
void bubblesort(node *&H) {
    node *p = H;
    node *wstaw = NULL;
    
H;
        
int counter 0;

    
0;
        
while (p) {
        counter++;
        p=p->next;
    }


    Add(H, findmin(H) - 1);
    p=H;
    for (int i = 0; i < counter; i++) {
        for (int j = 0; j < counter - 1; j++) {
            if (p->next->val > p->next->next->val) {
                wstaw = p->next;
                p->next = wstaw->next;
                wstaw->next = p->next->next;
                p->next->next = wstaw;
            }
            
(p!=NULL)
        {
                n++;
                
p = p->next;
        }
        p = H;
    }
    del(H);
show(H);

}

void insert(node *& H, int x)//wymaga aby lista byla posortowana
{
    node * pom = new node;//pomocniczy wskaźnik do skakania
    if (H == NULL)//jesli pusta lista to standardowo wstawiamy
    {
        Add(H, x);
    }
    else if (H->val > x)//jesli jest najmniejszy to także standardowo wstawiamy
    {
        Add(H, x);
    }
    else
    {
        pom = H;
        while (pom->next)
        {
            if (pom->next->val > x)// wstawianie jesli w środku
            {
                node * p = new node;
                node * pomocniczy = pom->next;
                p->val = x;
                pom->next = p;
                p->next = pomocniczy;
                return;
            }
            pom = pom->next;
        }
        //wstawianie jesli wskaznik idzie na koniec
        node * p = new node;
        node * pomocniczy = pom->next;
        p->val = x;
        pom->next = p;
        p->next = pomocniczy;



    }
del(H);
show(H);
}

int main()
{
    node* H = NULL;
  Add(H, 5);
  Add(H, 2);
   Add(H, 5);
  Add(H, 9);
   Add(H, 2);
  Add(H, 6);
   Add(H, 5);
  Add(H, 3);
   Add(H, 5);
  Add(H, 7);
   Add(H, 2);
  Add(H, 1);
 bubblesort(H);
  cout<
  insert(H,0);

    
p->next; //tu mi blad pokazuje 
        }
        
return 0;
}
n;
}

Replies to liczenie ile jest w liscie elementow rss

Title Name Language When
kochamciedawid ja cpp 4 Years ago.