Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VHB C++ DE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VHB Cpp
VHB C++ DE
Commits
6e36b66d
Commit
6e36b66d
authored
7 months ago
by
Rudi Buss
Browse files
Options
Downloads
Patches
Plain Diff
Update Solution Exercise 1 - Element.cpp
parent
b056b23d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Part 2/4. Linked lists/Solutions/Solution Exercise 1 - Element.cpp
+20
-23
20 additions, 23 deletions
... Linked lists/Solutions/Solution Exercise 1 - Element.cpp
with
20 additions
and
23 deletions
Part 2/4. Linked lists/Solutions/Solution Exercise 1 - Element.cpp
+
20
−
23
View file @
6e36b66d
...
...
@@ -2,33 +2,30 @@
using
namespace
std
;
class
Element
{
public:
int
value
;
/* Value of the element */
Element
*
next
;
/* Pointer to the next element */
class
Element
{
public:
int
value
;
/* Value of the element */
Element
*
next
;
/* Pointer to the next element */
};
int
main
()
{
int
main
()
{
int
input
=
1
;
Element
*
beginning
=
NULL
;
//The beginning points to NULL
Element
*
beginning
=
NULL
;
//
The beginning points to NULL
while
(
input
)
// as long as 0 is not entered
{
cout
<<
"Enter value: "
;
cin
>>
input
;
Element
*
object
=
new
Element
;
//Create new object with newly assigned address
object
->
value
=
input
;
object
->
next
=
beginning
;
//The last element points to the new element
beginning
=
object
;
//The new element becomes the last element
}
while
(
input
)
// as long as 0 is not entered
{
cout
<<
"Enter value: "
;
cin
>>
input
;
Element
*
object
=
new
Element
;
//
Create new object with newly assigned address
object
->
value
=
input
;
object
->
next
=
beginning
;
//
The last element points to the new element
beginning
=
object
;
//
The new element becomes the last element
}
while
(
beginning
!=
NULL
)
{
cout
<<
beginning
->
value
<<
endl
;
beginning
=
beginning
->
next
;
//The successor becomes the current node
}
while
(
beginning
!=
NULL
)
{
cout
<<
beginning
->
value
<<
endl
;
beginning
=
beginning
->
next
;
// The successor becomes the current node
}
return
0
;
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment