Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
prog1-fp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Adrian Seeligmüller
prog1-fp
Commits
9558b277
Commit
9558b277
authored
2 years ago
by
adrian s
Browse files
Options
Downloads
Patches
Plain Diff
update: avoid pointers
parent
ce0ff314
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
prog1-fp/fp.cpp
+40
-20
40 additions, 20 deletions
prog1-fp/fp.cpp
with
40 additions
and
20 deletions
prog1-fp/fp.cpp
+
40
−
20
View file @
9558b277
...
@@ -264,6 +264,15 @@ void make_connection(Liwanze& a, Liwanze& b)
...
@@ -264,6 +264,15 @@ void make_connection(Liwanze& a, Liwanze& b)
b
.
addconn_from
(
a
.
get_name
());
b
.
addconn_from
(
a
.
get_name
());
}
}
void
make_connection
(
int
a
,
int
b
,
vector
<
Liwanze
>&
lvec
)
{
lvec
.
at
(
a
).
addconn_to
(
lvec
.
at
(
b
).
get_name
());
lvec
.
at
(
b
).
addconn_from
(
lvec
.
at
(
a
).
get_name
());
}
void
init_connections
(
vector
<
Liwanze
>&
lvac
)
void
init_connections
(
vector
<
Liwanze
>&
lvac
)
{
{
make_connection
(
lvac
.
at
(
2
),
lvac
.
at
(
4
));
make_connection
(
lvac
.
at
(
2
),
lvac
.
at
(
4
));
...
@@ -308,14 +317,16 @@ void print_network(vector<Liwanze>& lvac)
...
@@ -308,14 +317,16 @@ void print_network(vector<Liwanze>& lvac)
cout
<<
endl
;
cout
<<
endl
;
}
}
void
user_addconn
(
vector
<
Liwanze
>&
lv
a
c
)
void
user_addconn
(
vector
<
Liwanze
>&
lv
e
c
)
{
{
string
sLiwanzA
{};
string
sLiwanzA
{};
string
sLiwanzB
{};
string
sLiwanzB
{};
bool
stringA
{
false
};
bool
boolLiwanzeA
{
false
};
bool
stringB
{
false
};
bool
boolLiwanzeB
{
false
};
Liwanze
*
a
{
nullptr
};
//Liwanze* a{ nullptr };
Liwanze
*
b
{
nullptr
};
//Liwanze* b{ nullptr };
int
iLiwanzA
;
int
iLiwanzB
;
...
@@ -334,17 +345,17 @@ void user_addconn(vector<Liwanze>& lvac)
...
@@ -334,17 +345,17 @@ void user_addconn(vector<Liwanze>& lvac)
}
}
for
(
auto
&
n
:
lvac
)
for
(
int
i
{};
i
<
lvec
.
size
();
i
++
)
{
{
if
(
n
.
get_name
()
==
sLiwanzA
)
if
(
lvec
.
at
(
i
)
.
get_name
()
==
sLiwanzA
)
{
{
a
=
&
n
;
iLiwanzA
=
i
;
string
A
=
true
;
boolLiwanze
A
=
true
;
}
}
}
}
if
(
string
A
==
false
)
if
(
boolLiwanze
A
==
false
)
{
{
cout
<<
"Diese Liwanze existiert nicht! Bitte nochmal versuchen "
;
cout
<<
"Diese Liwanze existiert nicht! Bitte nochmal versuchen "
;
continue
;
continue
;
...
@@ -363,27 +374,36 @@ void user_addconn(vector<Liwanze>& lvac)
...
@@ -363,27 +374,36 @@ void user_addconn(vector<Liwanze>& lvac)
}
}
for
(
auto
&
n
:
lvac
)
for
(
int
i
{};
i
<
lvec
.
size
();
i
++
)
{
{
if
(
n
.
get_name
()
==
sLiwanzB
)
if
(
lvec
.
at
(
i
)
.
get_name
()
==
sLiwanzB
)
{
{
b
=
&
n
;
iLiwanzB
=
i
;
string
B
=
true
;
boolLiwanze
B
=
true
;
}
}
}
}
if
(
string
B
==
false
)
if
(
boolLiwanze
B
==
false
)
{
{
cout
<<
"Diese Liwanze existiert nicht! Bitte nochmal versuchen "
;
cout
<<
"Diese Liwanze existiert nicht! Bitte nochmal versuchen "
;
continue
;
continue
;
}
}
make_connection
(
*
a
,
*
b
);
make_connection
(
lvec
.
at
(
iLiwanzA
),
lvec
.
at
(
iLiwanzB
));
cout
<<
a
->
get_name
()
<<
":"
<<
endl
;
a
->
print_tierone
();
cout
<<
lvec
.
at
(
iLiwanzA
).
get_name
()
<<
":"
<<
endl
;
lvec
.
at
(
iLiwanzA
).
print_tierone
();
cout
<<
lvec
.
at
(
iLiwanzB
).
get_name
()
<<
":"
<<
endl
;
lvec
.
at
(
iLiwanzB
).
print_tierone
();
boolLiwanzeA
=
false
;
boolLiwanzeB
=
false
;
cout
<<
b
->
get_name
()
<<
":"
<<
endl
;
//a = nullptr
;
b
->
print_tierone
()
;
//b = nullptr
;
...
...
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