Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct lista{
- int a;
- struct lista *next;
- };
- struct lista *head;
- void add(int x)
- {
- struct lista *temp = (struct lista*)malloc(sizeof(struct lista));
- temp->a = x;
- temp->next = NULL;
- if(head!=NULL){
- temp->next = head;
- }
- head=temp;
- }
- void print()
- {
- struct lista *temp = head;
- printf("List is: ");
- while(temp!=NULL)
- {
- printf(" %d",temp->a);
- temp = temp->next;
- }
- printf("\n");
- }
- int main ()
- {
- int x,i,a;
- printf("Ile chcesz elementow w liscie?\n");
- scanf("%d",&x);
- for(i=1; i<=x; i++)
- scanf("%d",&a);
- add(a);
- print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement