Advertisement
luluinstalock

Untitled

Jan 26th, 2016
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct Node{
  5. int x;
  6. struct Node *next;
  7. };
  8.  
  9. void wyswietl( struct Node *head ){
  10. while( head != NULL){
  11. printf("%d\n", head->x);
  12.  
  13. head=head->next;
  14. }
  15. }
  16.  
  17. int main(){
  18. struct Node *head;
  19. head = malloc(sizeof(struct Node));
  20.  
  21.  
  22.  
  23. struct Node *tail;
  24.  
  25. tail=head;
  26.  
  27.  
  28.  
  29. for(int i=-20;i<21;i=i+5){
  30. struct Node *tmp;
  31. tmp = malloc(sizeof(struct Node));
  32. tmp->x = i;
  33.  
  34. tail->next=tmp;
  35. tmp->next=NULL;
  36. tail=tmp;
  37.  
  38. }
  39.  
  40. wyswietl( head);
  41. free(head);
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement