Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG-material-public
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
Container 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
Yue Wu
PROG-material-public
Commits
4ba80bed
Commit
4ba80bed
authored
10 months ago
by
dali662d
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
b1e8ebe2
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
Sonderuebung/SoSe2024/SU02_2024_04_17/01_einkaufsliste.f95
+123
-0
123 additions, 0 deletions
Sonderuebung/SoSe2024/SU02_2024_04_17/01_einkaufsliste.f95
with
123 additions
and
0 deletions
Sonderuebung/SoSe2024/SU02_2024_04_17/01_einkaufsliste.f95
0 → 100644
+
123
−
0
View file @
4ba80bed
module
einkauf_mod
implicit
none
private
public
::
produkt
,
liste
,
ausgabe
,
delete
type
produkt
character
(
len
=
15
)
::
name
integer
::
menge
type
(
produkt
),
pointer
::
next
=>
NULL
()
end
type
type
liste
integer
::
laenge
type
(
produkt
),
pointer
::
head
=>
NULL
()
end
type
contains
subroutine
ausgabe
(
shoppinglist
)
type
(
liste
),
intent
(
in
)
::
shoppinglist
type
(
produkt
),
pointer
::
current
current
=>
shoppinglist
%
head
do
while
(
associated
(
current
))
write
(
*
,
'(A,X,I3)'
)
current
%
name
,
current
%
menge
current
=>
current
%
next
end
do
end
subroutine
ausgabe
subroutine
delete
(
shoppinglist
)
type
(
liste
),
intent
(
inout
)
::
shoppinglist
type
(
produkt
),
pointer
::
current
,
help
current
=>
shoppinglist
%
head
shoppinglist
%
head
=>
NULL
()
do
help
=>
current
%
next
deallocate
(
current
)
current
=>
help
if
(
.not.
associated
(
current
))
exit
end
do
end
subroutine
delete
end
module
einkauf_mod
program
einkaufsliste
use
einkauf_mod
implicit
none
type
(
liste
)
::
shoppinglist
!call build_mit_laenge(shoppinglist)
call
build_ohne_laenge
(
shoppinglist
)
call
ausgabe
(
shoppinglist
)
call
delete
(
shoppinglist
)
contains
subroutine
build_mit_laenge
(
shoppinglist
)
type
(
liste
),
intent
(
out
)
::
shoppinglist
type
(
produkt
),
pointer
::
current
integer
::
i
write
(
*
,
*
)
"Wie viele Elemente sollen auf die Liste kommen?"
read
(
*
,
*
)
shoppinglist
%
laenge
allocate
(
shoppinglist
%
head
)
current
=>
shoppinglist
%
head
write
(
*
,
*
)
"Gebe das erste Element ein und die gewuenschte Menge:"
read
(
*
,
*
)
current
%
name
,
current
%
menge
do
i
=
2
,
shoppinglist
%
laenge
allocate
(
current
%
next
)
current
=>
current
%
next
write
(
*
,
'(A,X,I3,X,A)'
)
"Element"
,
i
,
" und Menge:"
read
(
*
,
*
)
current
%
name
,
current
%
menge
end
do
end
subroutine
build_mit_laenge
subroutine
build_ohne_laenge
(
shoppinglist
)
type
(
liste
),
intent
(
out
)
::
shoppinglist
type
(
produkt
),
pointer
::
current
character
::
choice
allocate
(
shoppinglist
%
head
)
current
=>
shoppinglist
%
head
write
(
*
,
*
)
"Gebe das erste Element ein und die gewuenschte Menge:"
read
(
*
,
*
)
current
%
name
,
current
%
menge
shoppinglist
%
laenge
=
1
do
write
(
*
,
*
)
"Ein weiteres Element? (j/n)"
read
(
*
,
*
)
choice
if
(
choice
==
"n"
)
exit
allocate
(
current
%
next
)
current
=>
current
%
next
write
(
*
,
*
)
"Name und Menge :"
read
(
*
,
*
)
current
%
name
,
current
%
menge
shoppinglist
%
laenge
=
shoppinglist
%
laenge
+
1
end
do
write
(
*
,
'(A,I3,A)'
)
"Es wurden "
,
shoppinglist
%
laenge
,
" Elemente eingetragen."
end
subroutine
build_ohne_laenge
end
program
einkaufsliste
\ No newline at end of file
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