Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Z glowa
- struct element
- {
- int i;
- struct element * next;
- };
- void dodaj(struct element*Lista, int a)
- {
- struct element * wsk = malloc(sizeof(struct element));
- wsk->i=a;
- wsk->next=Lista->next;
- Lista->next=wsk;
- };
- struct element * utworz()
- {
- struct element * wskaznik = malloc(sizeof(struct element));
- wskaznik->next=NULL;
- return wskaznik;
- };
- int porownaj(struct element *Lista, struct element *Lista2)
- {
- int isSame = 1;
- while(Lista->next != NULL && Lista2->next != NULL)
- {
- Lista = Lista->next;
- Lista2 = Lista2->next;
- if(Lista->i != Lista2->i)
- {
- isSame = 0;
- break;
- }
- }
- return isSame;
- }
- int main()
- {
- struct element* l1 = utworz();
- dodaj(l1,2);
- struct element* l2 = utworz();
- dodaj(l2,3);
- printf("%i",porownaj(l1,l2));
- return 0;
- }
- void wyczysc(struct element * Lista)
- {
- struct element * wsk=Lista->next;
- Lista=wsk;
- while(Lista!=NULL)
- {
- Lista=Lista->next;
- free(wsk);
- wsk=Lista;
- }
- }
- struct element * znajdz(struct element* Lista,int a)
- {
- Lista=Lista->next;
- while((Lista!=NULL)&&(Lista->i!=a))
- Lista=Lista->next;
- return Lista;
- };
- void usun(struct element* Lista,int a)
- {
- struct element * wsk;
- while((Lista->next!=NULL)&&(Lista->next->i!=a))
- Lista=Lista->next;
- if(Lista->next!=NULL)
- {
- wsk=Lista->next;
- Lista->next=wsk->next;
- free(wsk);
- }
- }
- int minimum(struct element* Lista)
- {
- int min=Lista->next->i;
- while(Lista->next!=NULL)
- {
- Lista=Lista->next;
- if(Lista->i<min)
- min=Lista->i;
- }
- return min;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement