Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- typedef struct node
- {
- int a;
- struct node *next, *prev;
- }node;
- node *head=NULL, *tail=NULL;
- void insert_at_last()
- {
- node *N=(node*)malloc(sizeof(node));
- scanf("%d", &N->a);
- N->next=NULL;
- if(head==NULL)
- {
- head=N;
- tail=N;
- return;
- }
- else
- {
- tail->next=N;
- N->prev=tail;
- }
- }
- void min()
- {
- int min=0;
- node *list=head;
- if(head==NULL)
- {
- printf("This is Empty.\n");
- return;
- }
- else
- {
- while(list!=NULL)
- {
- if(list->a<min)
- {
- min=list->a;
- }
- list=list->next;
- }
- }
- printf("Min: %d\n", min);
- }
- int main()
- {
- int i,x;
- for(i=1; i<=4; i++)
- {
- insert_at_last();
- }
- min();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement