#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct element {
int k;
char tekst[50];
struct element *prev;
struct element *next;
int id;
};
void lista_wyswietl(struct element *head);
struct element *lista_dodaj(struct element *head, struct element *nowy);
struct element *lista_usun(struct element *head, struct element *nowy);
struct element *lista_posz(struct element *head, int klucz);
struct element *lista_odwroc(struct element *head);
main()
{
struct element *head=NULL, *nowy=NULL;
char z;
int liczba, klucz, index=0;
while(1)
{
printf("nco chcesz zrobic?");
printf("nd-dodac");
printf("ns-szukac");
printf("nu-usunac");
printf("no-odwrocic liste");
printf("nw-wyswietlic");
printf("nq-wyjscn");
fflush(stdin);
z=getchar();
switch(z)
{
case 'd': nowy=(struct element*)malloc(sizeof(struct element));
printf("npodaj wartosc elementu do wstawienia: ");
scanf("%d",&liczba);
nowy->k=liczba;
nowy->id=index++;
if(nowy->id%2!=0)
{
printf("nPodaj tekst do wstawienia: ");
fflush(stdin);
scanf("%s",nowy->tekst);
}
else strcpy(nowy->tekst," ");
head=lista_dodaj(head,nowy);
printf("%d",head->id);
break;
case 'w': lista_wyswietl(head);
break;
case 'u' :
break;
case 'o' :head=lista_odwroc(head);
break;
case 's' :fflush(stdin);
printf("nPodaj wartosc klucza jaka chcesz wyszukac");
scanf("%d",&klucz);
printf("%d",*lista_posz(head, klucz));
break;
case 'q': return 0;
}
}
}
void lista_wyswietl(struct element *head)
{
struct element *x=head;
while(x!=NULL)
{
printf("%d",x->k);
printf("%sn",x->tekst);
x=x->next;
}
}
struct element *lista_dodaj(struct element *head, struct element *nowy)
{
nowy->prev=NULL;
nowy->next=head;
if(head!=NULL)
head->prev=nowy;
head=nowy;
return head;
}
struct element *lista_usun(struct element *head, struct element *x)
{
if(x->prev!=NULL)
(x->prev)->next=x->next;
else head=x->next;
if (x->next!=NULL)
(x->next)->prev=x->prev;
}
struct element *lista_posz(struct element *head, int klucz)
{
struct element *x=NULL;
x=head;
while(x!=NULL && x->k!=klucz)
x=x->next;
return x;
}
struct element *lista_odwroc(struct element *head)
{
struct element *x=NULL;
struct element *temp=NULL;
struct element *temp1=NULL;
x=head;
while(x!=NULL)
{temp1=(struct element*)malloc(sizeof(struct element));
temp1->k=x->k;
temp=lista_dodaj(temp,temp1);
x=x->next;
}
return temp;
}
{"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"}