#include <iostream>
using namespace std;
/*
1. zamienia co 2 miejsce
2. do funkcji x, i to co przed x na koniec
3. zamiana parami
*/
struct node
{
int val;
node *next;
};
void add(node *&H, int x)
{
node *p = new node;
p->val = x;
p->next = H;
H = p;
}
void show(node *H)
{
cout << "H->";
node *p = H;
while (p != NULL)
{
cout << p->val << "->";
p = p->next;
}
cout << "NULL\n";
cout << endl;
}
void del(node *&H)
{
if (H != 0)
{
node *p = H;
H = H->next;
delete p;
}
cout << endl;
}
void parzystaPo(node *&H)
{
if (H != NULL)
{
node *tmp = H;
while (tmp->next!= NULL)
{
node *p = new node;
p->val = tmp->next->val;
p->next = tmp->next;
tmp->next = p;
tmp = p->next->next;
}
}
}
void wyrzucPrzed(node *&H, int x)
{
node *p = H;
node *szuk = new node;
while (H != NULL)
{
if (p->val == x)
{
szuk->val = x;
}
else p = p->next;
}
while (H != NULL)
{
node *koniec = new node;
koniec->next = NULL;
koniec->val = x;
p = H;
if (p)
{
while (p->next) p = p->next;
p->next = koniec;
}
else H = koniec;
}
}
int main()
{
node *H = NULL;
int n;
cout << "Ile elementow utworzymy? : ";
cin >> n;
for (int i = 0; i < n; i++)
{
int y;
cout << "Podaj liczbe: ";
cin >> y;
add(H, y);
}
/*int x;
cout << "Z przed jakiej liczby wyrzucic na koniec: ";
cin >> x;
*/
show(H);
parzystaPo(H);
show(H);
system("pause");
}
{"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"}