Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bez glowy
- struct element
- {
- int i;
- struct element * next;
- };
- struct element * utworz()
- {
- struct element * wskaznik = malloc(sizeof(struct element));
- wskaznik->next=NULL;
- return wskaznik;
- };
- void dodaj(struct element*Lista, int a)
- {
- struct element * wsk = malloc(sizeof(struct element));
- wsk->i=a;
- wsk->next=Lista->next;
- Lista->next=wsk;
- };
- 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();
- struct element* l2 = utworz();
- dodaj(l1,1);
- dodaj(l1,1);
- dodaj(l1,1);
- dodaj(l2,1);
- dodaj(l2,1);
- dodaj(l2,1);
- printf("%i",porownaj(l1,l2));
- return 0;
- }
- struct element*znajdz(struct element*Lista, int a)
- {
- while((Lista!=NULL)&&(Lista->i!=a))
- {
- Lista=Lista->next;
- }
- return Lista;
- };
- void wyczysc(struct element *Lista)
- {
- struct element * wsk=Lista;
- while(Lista!=NULL)
- {
- Lista=Lista->next;
- free(wsk);
- wsk=Lista;
- }
- }
- struct element * usun(struct element* Lista, int a)
- {
- struct element * wsk,*wsk2;
- if(Lista=NULL)
- return Lista;
- wsk=Lista;
- if(Lista->i==a)
- {
- Lista=Lista->next;
- free(wsk);
- }
- else{
- while((wsk->next!=NULL)&&(wsk->next->i!=a))
- wsk=wsk->next;
- wsk->next=wsk2->next;
- free(wsk2);
- }
- return Lista;
- };
- int minimum(struct element*Lista)
- {
- int min=Lista->i;
- while(Lista!=NULL)
- {
- if(Lista->i<min)
- min=Lista->i;
- Lista=Lista->next;
- }
- return min;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement