forked from skywalker290/hack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbtcodes.cpp
101 lines (65 loc) · 1.27 KB
/
btcodes.cpp
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
#include<iostream>
using namespace std;
class node{
public:
int data;
node *next;
node(int x){
data = x;
next= NULL;
}
};
class LL{
public:
node *head;
node *tail;
LL(){
tail=head=NULL;
}
void insertatlast(int x){
node *p= new node(x);
if(head==NULL){
head=tail=p;
}
else if(tail->next=p){
tail=p;
}
}
void digitll(int num){
while(num){
int x;
x=num%10;
node *temp=new node(x);
if(head==NULL){
head=tail=temp;
}
else{
temp->next=head;
head=temp;
}
num=num/10;
}
}
void display(){
node *p;
p=head;
while(p){
cout<<endl;
cout<<p->data<<" ";
p=p->next;
}
cout<<endl;
}
};
int main(){
cout<<"============"<<endl;
LL obj;
int num;
cout<<"enter number::";
cin>>num;
obj.digitll(num);
obj.display();
cout<<endl;
cout<<"============";
return 0;
}