Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Programování 1 pro matematiky
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Martin Mareš
Programování 1 pro matematiky
Commits
b0d4e249
Commit
b0d4e249
authored
5 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
02: Příklady s posloupností ukončenou -1
parent
6af67988
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
02-cykly/02-cykly.tex
+8
-0
8 additions, 0 deletions
02-cykly/02-cykly.tex
02-cykly/posloupnost-max.py
+18
-0
18 additions, 0 deletions
02-cykly/posloupnost-max.py
02-cykly/posloupnost-soucet.py
+13
-0
13 additions, 0 deletions
02-cykly/posloupnost-soucet.py
with
39 additions
and
0 deletions
02-cykly/02-cykly.tex
+
8
−
0
View file @
b0d4e249
...
@@ -113,4 +113,12 @@ Existuje zkratka:
...
@@ -113,4 +113,12 @@ Existuje zkratka:
% ----------------------------------------------------------------------
% ----------------------------------------------------------------------
\begin{frame}
{
Příklad: sčítáme posloupnost čísel
}
\verbatiminput
{
posloupnost-soucet.py
}
\end{frame}
% ----------------------------------------------------------------------
\end{document}
\end{document}
This diff is collapsed.
Click to expand it.
02-cykly/posloupnost-max.py
0 → 100755
+
18
−
0
View file @
b0d4e249
#!/usr/bin/env python3
# Načítá čísla ze vstupu ukončená -1,
# vypíše druhé největší z nich
m1
=
0
# Zatím největší číslo
m2
=
0
# Zatím druhé největší
while
True
:
n
=
int
(
input
())
if
n
==
-
1
:
break
if
n
>
m1
:
m1
,
m2
=
n
,
m1
elif
n
>
m2
:
m2
=
n
print
(
m2
)
This diff is collapsed.
Click to expand it.
02-cykly/posloupnost-soucet.py
0 → 100755
+
13
−
0
View file @
b0d4e249
#!/usr/bin/env python3
# Načítá čísla ze vstupu ukončená -1,
# vypíše jejich součet
s
=
0
while
True
:
n
=
int
(
input
())
if
n
==
-
1
:
break
s
+=
n
print
(
s
)
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