#include <iostream>
using namespace std;
struct Elem{
int liczba;
Elem*next;
};
bool funkcja (Elem*&glowa, int numer)
{
if (glowa==NULL){
return false;
}
int max = glowa->liczba;
Elem*akt=glowa;
while(akt!=NULL)
{
if(akt->liczba>max){
max=akt->liczba;
}
akt=akt->next;
}
Elem*ost=glowa;
while(ost->next!=NULL)
{
ost=ost->next;
}
Elem*nowy=new Elem;
nowy->liczba=max;
nowy->next=NULL;
ost->next=nowy;
akt=glowa;
int n=0;
while(akt!=NULL)
{
n++;
akt=akt->next;
}
if ((numer<=0) ||(numer>n)){
return false;
}
if (numer==1){
Elem*u=glowa;
glowa=glowa->next;
delete u;
}else{
Elem*pu=glowa;
for(int i=1; i<numer-1; i++){
pu=pu->next;
}
Elem*uu=pu->next;
pu->next=uu->next;
delete uu;
}
return true;
}
Elem* stworz ()
{
Elem* glowa = new Elem;
Elem* tmp = glowa;
do {
cin >> glowa -> liczba; cout << " ";
tmp -> next = new Elem;
tmp = tmp -> next;
tmp -> next = NULL;
} while (tmp->liczba!=0);
return tmp;
}
int main()
{
Elem *glowa = NULL;
stworz();
funkcja(glowa,4);
return 0;
}
{"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"}