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
37767e67
Commit
37767e67
authored
1 year ago
by
dali662d
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
648422c4
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
Sonderuebung/WiSe23-24/SU03_2023_11_07/02_taschenrechner_mit_if_v2.f95
+41
-0
41 additions, 0 deletions
...WiSe23-24/SU03_2023_11_07/02_taschenrechner_mit_if_v2.f95
with
41 additions
and
0 deletions
Sonderuebung/WiSe23-24/SU03_2023_11_07/02_taschenrechner_mit_if_v2.f95
0 → 100644
+
41
−
0
View file @
37767e67
! Enthaelt weniger WRITE Anweisungen (weniger Redudanz)
! benoetigt dafuer eine extra Logical-Variable ob die Rechnung durchgefuehrt wurde
! (wegen Division durch 0)
program
taschenrechner
implicit
none
INTEGER
::
a
,
b
! Variablen
CHARACTER
::
op
! Operator
INTEGER
::
res
! Result
LOGICAL
::
calc
=
.true.
WRITE
(
*
,
*
)
"Gebe zwei Zahlen ein!"
READ
(
*
,
*
)
a
,
b
WRITE
(
*
,
*
)
"Gebe einen Rechenoperator (+,-,*,/) ein!"
READ
(
*
,
*
)
op
IF
(
op
==
"+"
)
THEN
res
=
a
+
b
ELSEIF
(
op
==
"-"
)
THEN
res
=
a
-
b
ELSEIF
(
op
==
"*"
)
THEN
res
=
a
*
b
ELSEIF
(
op
==
"/"
)
THEN
IF
(
b
==
0
)
THEN
WRITE
(
*
,
*
)
"Division durch 0 ist veboten!"
calc
=
.false.
ELSE
res
=
a
/
b
END
IF
ELSE
WRITE
(
*
,
*
)
"Der Eingegebene Operator ist ungueltig."
calc
=
.false.
END
IF
IF
(
calc
)
WRITE
(
*
,
*
)
"Das Ergebnis ist "
,
res
end
program
taschenrechner
\ 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