-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinary_rotation.cpp
More file actions
83 lines (71 loc) · 1.3 KB
/
Copy pathbinary_rotation.cpp
File metadata and controls
83 lines (71 loc) · 1.3 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
using namespace std;
struct node
{
int data;
node *link;
};
class SSL
{
int n = 0;
node *head;
public:
SSL() { head = NULL; }
void create()
{
int n;
cout << "Enter the decimal number: ";
cin >> n;
while (head != NULL)
{
node *temp = head;
head = head->link;
delete temp;
}
node *temp = head;
for (int i = n; i > 0; i = i / 2)
{
node *nn = new node;
nn->data = i % 2;
nn->link = head;
head = nn;
}
}
void display()
{
node *temp = head;
while (temp != NULL)
{
cout << temp->data << "->";
temp = temp->link;
}
cout << "NULL" << endl;
}
void rotation(int x)
{
while (x > 0)
{
node *temp = head;
node *tail = head->link;
while (temp->link != NULL)
{
temp = temp->link;
}
temp->link = head;
head->link = NULL;
head = tail;
x--;
}
}
void get_decimal()
{
}
};
int main()
{
SSL lst;
lst.create();
lst.display();
lst.rotation(1);
lst.display();
}