Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include "stdlib.h"
- typedef struct s{
- int data;
- struct s *prev, *next;
- }node;
- node* new1(){
- node* temp =(node *)malloc(sizeof(node));
- return temp;
- }
- int main(int argc, char const *argv[]){
- int n;
- node *head, *temp, *start;
- head = new1() ;
- head -> next = NULL;
- scanf("%d", &n);
- scanf("%d", &(head->data));
- while(--n){
- temp = new1();
- scanf("%d", &(temp->data));
- temp->next = head;
- head = temp;
- }
- start = head;
- while(start != NULL){
- printf("%d ", start->data);
- start = start->next;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment