Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- typedef struct lista
- {
- char *wskaznik;
- int numer;
- struct lista *next;
- }
- listaa;
- listaa *pierwszy, *active;
- void funkcja(numer)
- {
- int i;
- listaa *dodatkowy, *previous;
- dodatkowy=(listaa *)malloc(sizeof(listaa));
- scanf("%d", &dodatkowy->numer);
- if (pierwszy==NULL)
- {
- pierwszy=dodatkowy;
- active=pierwszy;
- previous=NULL;
- active->next=NULL;
- return;
- }
- active=pierwszy;
- previous=active;
- if (dodatkowy->numer < active->numer)
- {dodatkowy->next=active;
- pierwszy=dodatkowy;
- return;
- }
- while(active!=NULL)
- {
- if (dodatkowy->numer >= active->numer)
- {
- previous=active;
- active=active->next;
- }
- else
- {
- if(dodatkowy->numer <= active->numer)
- {
- previous->next=dodatkowy;
- dodatkowy->next=active;
- return;
- }}
- }
- if(active==NULL)
- {
- previous->next=dodatkowy;
- dodatkowy->next=NULL;
- return;
- }
- }
- int main(int argc, char **argv)
- { int i;
- funkcja();
- funkcja();
- funkcja();
- funkcja();
- active=pierwszy;
- for(i=0;i<4;i++)
- {
- printf("%d \n", active->numer);
- active=active->next;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement