Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct node {
- int data;
- struct node *next;
- };
- struct node* head = NULL;
- void insert(int n) {
- struct node*temp;
- temp = (struct node*)malloc(sizeof(struct node));
- temp->data = n;
- temp->next = head;
- head = temp;
- }
- void print() {
- struct node* temp;
- temp = head;
- while(temp != NULL) {
- printf("%d\t" , temp->data);
- temp = temp->next;
- }
- }
- int main ()
- {
- int x, m, n;
- scanf("%d" , &m);
- for(x = 1; x <= m; x++) {
- scanf("%d" , &n);
- insert(n);
- }
- print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement