#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 n = 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
Title |
Name |
Language |
UNIX |
When |
kochamciedawid |
ja |
cpp |
1567103605 |
4 Years ago. |
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}