Advertisement
nontawat1996

Gift-HW

Mar 9th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. typedef struct node{
  5.     int value;
  6.     struct node *next;
  7. }NODE;
  8.  
  9. void main(){
  10.     NODE *head=NULL;
  11.     int i,x=3;
  12.     struct node *t;
  13.  
  14.     head=(NODE*) malloc (sizeof(NODE));
  15.     head->value=x;
  16.     t=head;
  17.  
  18.     for(i=1;i<50;i++){
  19.         t->next=(NODE*) malloc (sizeof(NODE));
  20.         t=t->next;
  21.         t->value=x;
  22.         t->next=NULL;
  23.         x+=2;
  24.     }
  25.     for(t=head; t!=NULL ; t=t->next){      
  26.         printf("%d ->",t->value);
  27.     }  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement