Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PPC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Vojtěch Novotný
PPC
Commits
88345dcd
Commit
88345dcd
authored
2 weeks ago
by
Vojtěch Novotný
Browse files
Options
Downloads
Patches
Plain Diff
cviceni 3
parent
14de5451
No related branches found
Branches containing commit
No related tags found
1 merge request
!4
stabilni verze semestralni prace, 3 cviceni, domaci ukol 1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cviceni/3_c/priklad1.cpp
+95
-0
95 additions, 0 deletions
cviceni/3_c/priklad1.cpp
with
95 additions
and
0 deletions
cviceni/3_c/priklad1.cpp
0 → 100644
+
95
−
0
View file @
88345dcd
#include
<vector>
#include
<iostream>
#include
<algorithm>
int
main
()
{
// neinicializovaný vektor cisel typu int, nulové velikosti
std
::
vector
<
int
>
a
;
std
::
cout
<<
"velikost a je "
<<
a
.
size
()
<<
std
::
endl
;
a
.
push_back
(
10
);
std
::
cout
<<
"velikost a je "
<<
a
.
size
()
<<
std
::
endl
;
a
.
resize
(
10
);
for
(
int
i
=
0
;
i
<
a
.
size
();
i
++
)
{
std
::
cout
<<
a
[
i
]
<<
" "
;
}
std
::
cout
<<
std
::
endl
;
// std::vector<int>::iterator i;
for
(
auto
i
=
a
.
begin
();
i
!=
a
.
end
();
i
++
)
{
std
::
cout
<<
*
i
<<
" "
;
}
std
::
cout
<<
std
::
endl
;
for
(
int
x
:
a
)
std
::
cout
<<
x
<<
" "
;
std
::
cout
<<
std
::
endl
;
for
(
int
&
x
:
a
)
x
=
5
;
for
(
const
int
&
x
:
a
)
std
::
cout
<<
x
<<
" "
;
std
::
cout
<<
std
::
endl
;
int
b
[]
=
{
1
,
2
,
3
,
4
};
int
*
pb
=
&
b
[
1
];
// pb+1 ukazatel
std
::
cout
<<
*
(
pb
+
1
)
<<
std
::
endl
;
int
&
rb
=
b
[
1
];
std
::
cout
<<
rb
+
10
<<
std
::
endl
;
for
(
auto
i
=
a
.
begin
();
i
!=
a
.
end
()
+
1
;
i
++
)
{
std
::
cout
<<
*
i
<<
" "
;
}
std
::
cout
<<
std
::
endl
;
try
{
for
(
int
i
=
0
;
i
<
a
.
size
();
i
++
)
{
std
::
cout
<<
a
[
i
]
<<
"/"
<<
a
.
at
(
i
)
<<
" "
;
}
throw
1
;
std
::
cout
<<
std
::
endl
;
}
catch
(
std
::
out_of_range
&
e
)
{
std
::
cerr
<<
"chyba: "
<<
e
.
what
()
<<
std
::
endl
;
}
catch
(
int
e
)
{
std
::
cerr
<<
"
\n
chyba"
<<
e
<<
std
::
endl
;
}
std
::
vector
<
int
>
z
{
10
,
11
,
9
,
8
,
65
,
3
,
100
};
for
(
int
&
x
:
z
)
std
::
cout
<<
x
<<
" "
;
std
::
cout
<<
std
::
endl
;
std
::
sort
(
z
.
begin
(),
z
.
end
(),
[](
int
a
,
int
b
)
{
return
a
>
b
;
});
for
(
int
&
x
:
z
)
std
::
cout
<<
x
<<
" "
;
std
::
cout
<<
std
::
endl
;
std
::
vector
<
int
>
zz
(
z
.
size
());
std
::
copy_if
(
z
.
begin
(),
z
.
end
(),
zz
.
begin
(),
[](
int
a
)
{
if
(
a
>
10
)
return
a
;
else
return
0
;
});
for
(
int
&
x
:
zz
)
std
::
cout
<<
x
<<
" "
;
std
::
cout
<<
std
::
endl
;
}
\ 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