-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOctober6.cpp
More file actions
110 lines (71 loc) · 1.48 KB
/
Copy pathOctober6.cpp
File metadata and controls
110 lines (71 loc) · 1.48 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <iostream>
using namespace std;
class Node{
public:
int val;
Node* next;
Node(int val){
this -> val = val;
this -> next = NULL;
}
};
int main(){
Node a(10);
Node b(20);
Node c(30);
Node d(40);
a.next = &b;
b.next = &c;
c.next = &d;
Node temp = a;
while(true){
cout << temp.val << " ";
if(temp.next == NULL) break;
temp = *(temp.next);
}
return 0;
}
// #include <iostream>
// using namespace std;
// class Node{
// public:
// int val;
// Node* next;
// Node(int val){
// this -> val = val;
// this -> next = NULL;
// }
// };
// int main(){
// // 10 20 30 40
// // Node a;
// // a.val = 10;
// // a.next = &b;
// // Node b;
// // b.val = 20;
// // b.next = &c;
// // Node c;
// // c.val = 30;
// // c.next = &d;
// // Node d;
// // d.val = 40;
// // d.next = NULL;
// Node a(10);
// Node b(20);
// Node c(30);
// Node d(40);
// a.next = &b;
// b.next = &c;
// c.next = &d;
// d.next = NULL;
// //cout << (a.next) -> val;
// //cout << (*(a.next)).val << endl;
// // cout << c.val << endl;
// // cout << ((a.next) -> next) -> val << endl;
// cout << d.val << endl;
// cout << (a.next) -> next -> next -> val;
// // cout << &a << endl;
// // cout << a.val << endl;
// // cout << a.next << endl;
// return 0;
// }