Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct element {
- int info;
- struct element *next;
- };
- struct element *addToTop(struct element *p0, int v1);
- void addToBottom(struct element *p1, int v1);
- struct element *deleteOcc();
- void viewList(struct element *p2);
- int main()
- {
- int v=1;
- struct element *p;
- p=malloc(sizeof(struct element));
- while(v!=0)
- {
- scanf("%d", &v);
- if(v>0 && v%2==0)
- p=addToTop(p,v);
- else if(v>0 && v%2!=0)
- addToBottom(p,v);
- else if(v<0)
- deleteOcc(p,v);
- }
- viewList(p);
- return 0;
- }
- struct element *addToTop(struct element *p0, int v1)
- {
- struct element *punt;
- punt=malloc(sizeof(struct element));
- punt->info=v1;
- punt->next=p0->next;
- p0->next=punt;
- return p0;
- }
- void addToBottom(struct element *p1, int v1)
- {
- struct element *punta;
- punta=malloc(sizeof(struct element));
- punta->info=v1;
- while(p1!=NULL)
- {
- if(p1->next==NULL)
- {
- p1->next=punta;
- punta->next=NULL;
- break;
- }
- p1=p1->next;
- }
- }
- struct element *deleteOcc(struct element lista, int v1)
- {
- }
- void viewList(struct element *p2)
- {
- //p2=p2->next;
- while(p2!=NULL)
- {
- printf("%d\n", p2->info);
- p2=p2->next;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement