File tree 3 files changed +63
-1
lines changed
3 files changed +63
-1
lines changed Original file line number Diff line number Diff line change 1
1
10
2
2
20
3
+ 30
4
+ 40
5
+ 50
6
+ ------------------
7
+ Line Break
8
+ ------------------
9
+ 10
3
10
20
4
- 20
11
+ 30
12
+ 40
13
+ 50
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ class Node
5
+ {
6
+ public:
7
+ int val;
8
+ Node *next;
9
+
10
+ Node (int val)
11
+ {
12
+ this ->val = val;
13
+ this ->next = NULL ;
14
+ }
15
+ };
16
+
17
+ int main ()
18
+ {
19
+ Node *head = new Node (10 );
20
+ Node *a = new Node (20 );
21
+ Node *b = new Node (30 );
22
+ Node *c = new Node (40 );
23
+ Node *d = new Node (50 );
24
+
25
+ head->next = a;
26
+ a->next = b;
27
+ b->next = c;
28
+ c->next = d;
29
+
30
+ /* cout << head->val << endl;
31
+ cout << head->next->val << endl;
32
+ cout << head->next->next->val << endl; */
33
+
34
+ Node *tmp = head;
35
+
36
+ while (tmp != NULL )
37
+ {
38
+ cout << tmp->val << endl;
39
+ tmp = tmp->next ;
40
+ }
41
+ cout << " ------------------" << endl
42
+ << " Line Break"
43
+ << endl
44
+ << " ------------------" << endl;
45
+ tmp = head;
46
+ while (tmp != NULL )
47
+ {
48
+ cout << tmp->val << endl;
49
+ tmp = tmp->next ;
50
+ }
51
+
52
+ return 0 ;
53
+ }
You can’t perform that action at this time.
0 commit comments