forked from a-r-nida/HactoberFest2020-Beginers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Revdoubly. C
64 lines (62 loc) · 923 Bytes
/
Revdoubly. C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct node{
int data;
struct node *next;
struct node *prev;
};
struct node *head,*tail;
void create(){
struct node *newnode;
int choice;
head=NULL;
while(choice){
newnode=(struct node*)malloc(sizeof(struct node));
printf("enter data");
scanf("%d",&newnode->data);
newnode->prev=NULL;
newnode->next=NULL;
if(head == NULL){
head=newnode;
tail=newnode;
}
else{
tail->next=newnode;
newnode->prev=tail;
tail=newnode;
}
printf("do you want to continue(1,0)?");
scanf("%d",&choice);
}
}
void print(){
struct node * temp;
temp=head;
while(temp!=NULL){
printf("%d",temp->data);
temp=temp->next;
}
}
void rever(){
struct node * pnode,* nnode;
pnode=head;
while(pnode!=NULL){
nnode=pnode->next;
pnode->next=pnode->prev;
pnode->prev=nnode;
pnode=nnode;
}
pnode=head;
head=tail;
tail=pnode;
}
void main(){
clrscr();
create();
print();
rever();
printf("\n");
print();
getch();
}