Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct osoba
- {
- int wiek;
- struct osoba *next;
- };
- struct osoba *head;
- struct osoba *last;
- struct osoba *pom;
- int main()
- {
- printf("------------------------------------------\n");
- printf("Wyjscie z programu: 0\n");
- printf("Tworzenie listy: 1\n");
- printf("Dodawanie elementu na poczatek listy: 2\n");
- printf("Dodawanie elementu na koniec listy: 3\n");
- printf("Dodawanie elementu po zadanym listy: 4\n");
- printf("Usuwanie elementu wybranego listy: 5\n");
- printf("------------------------------------------\n");
- int choice,x;
- scanf("%d",&choice);
- while(choice!=0)
- {
- if(choice==0)
- {
- break;
- }
- else if(choice==1)
- {
- create();
- }
- else if(choice==2)
- {
- printf("Podaj wiek: ");
- scanf(" %d",&x);
- dodajElement(x);
- }
- }
- return 0;
- }
- void create()
- {
- head=NULL;
- last=NULL;
- }
- void dodajElement(int x)
- {
- pom=(struct osoba*)malloc(sizeof(struct osoba));
- head=pom;
- pom->next=NULL;
- pom->wiek=x;
- printf("%d\n",pom->wiek);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement