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
Tomáš Pachman
PPC
Commits
8fd9c13b
Commit
8fd9c13b
authored
2 weeks ago
by
Tomáš Pachman
Browse files
Options
Downloads
Patches
Plain Diff
edit
parent
f26d27a6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cviceni/cv03/map.cpp
+28
-0
28 additions, 0 deletions
cviceni/cv03/map.cpp
cviceni/cv03/vector.cpp
+85
-0
85 additions, 0 deletions
cviceni/cv03/vector.cpp
with
113 additions
and
0 deletions
cviceni/cv03/map.cpp
0 → 100644
+
28
−
0
View file @
8fd9c13b
#include
<iostream>
#include
<map>
//#include <unordered_map>
int
main
(
void
){
std
::
map
<
std
::
string
,
int
>
D
;
D
[
"Tokyo"
]
=
37833000
;
D
[
"Dilli"
]
=
24953000
;
D
[
"Sanghaj"
]
=
22991000
;
D
[
"Maxico City"
]
=
20843000
;
D
[
"Sao Paulo"
]
=
20831000
;
std
::
cout
<<
"Zadej mesto: "
<<
std
::
endl
;
std
::
string
city
;
std
::
cin
>>
city
;
if
(
D
.
find
(
city
)
==
D
.
end
()){
std
::
cerr
<<
"takove mesto neznam"
<<
std
::
endl
;
}
else
{
std
::
cout
<<
city
<<
" ma populaci "
<<
D
[
city
]
<<
std
::
endl
;
}
std
::
map
<
std
::
string
,
std
::
string
>
mapSQL
;
mapSQL
[
"getTemperatureById"
]
=
"SELECT *FROM TEMPERATURE WHERE TEMP_SEND_ID =%id"
;
mapSQL
[
"getTemperature"
]
=
"SELECT *FROM TEMPERATURE"
;
return
0
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
cviceni/cv03/vector.cpp
0 → 100644
+
85
−
0
View file @
8fd9c13b
#include
<iostream>
#include
<vector>
#include
<algorithm>
//*pro funkci sort
#include
<ctime>
void
print_vec_int
(
std
::
vector
<
int
>
vec
){
for
(
auto
it
=
vec
.
begin
();
it
!=
vec
.
end
();
++
it
){
std
::
cout
<<*
it
<<
", "
;
}
std
::
cout
<<
std
::
endl
;
}
int
main
(
void
){
//*vytvoreni vektoru
std
::
vector
<
int
>
vint
;
std
::
vector
<
float
>
vfloat
(
10
);
std
::
vector
<
char
>
vchar
=
{
'a'
,
'h'
,
'o'
,
'j'
};
//*rezervovani mista pro 16 prvku
vchar
.
reserve
(
16
);
std
::
cout
<<
"vint.size() = "
<<
vint
.
size
()
<<
std
::
endl
;
std
::
cout
<<
"vfloat.size() = "
<<
vfloat
.
size
()
<<
std
::
endl
;
std
::
cout
<<
"vchar.size() = "
<<
vchar
.
size
()
<<
" ,vchar.capacity() = "
<<
vchar
.
capacity
()
<<
std
::
endl
;
vint
.
reserve
(
10
);
//*resize vektoru na 10 prvku
vint
.
resize
(
10
);
for
(
int
idx
=
0
;
idx
<
vint
.
capacity
();
++
idx
){
//std::cout<<vint[idx] << ", ";
try
{
vint
.
at
(
idx
)
=
idx
;
std
::
cout
<<
vint
.
at
(
idx
)
<<
", "
;
}
catch
(
std
::
out_of_range
e
){
std
::
cout
<<
"odchyceno out of range:"
<<
e
.
what
()
<<
std
::
endl
;
}
catch
(
const
std
::
exception
e
){
std
::
cout
<<
"odchycena vyjimka:"
<<
e
.
what
()
<<
std
::
endl
;
}
catch
(...){
std
::
cout
<<
"odchycena vyjimka ale nevim jaka"
<<
std
::
endl
;
}
}
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
"vfloat = "
;
//*for each cyklus
for
(
float
f
:
vfloat
){
std
::
cout
<<
f
<<
", "
;
}
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
"vchar = "
;
//*iterator (++it se posune na dalsi prvek)
///iterujeme od zacatku do konce pole
//for(std::vector<char>::iterator it = vchar.begin(); it != vchar.end(); ++it){
//*auto - kompilator si vybere spravny typ
for
(
auto
it
=
vchar
.
begin
();
it
!=
vchar
.
end
();
++
it
){
std
::
cout
<<*
it
<<
", "
;
}
std
::
cout
<<
std
::
endl
;
//*randomizace vektoru
srand
(
time
(
NULL
));
for
(
int
idx
=
0
;
idx
<
vint
.
size
();
++
idx
){
int
temp
,
randomidx
=
vint
.
at
(
randomidx
);
vint
.
at
(
idx
)
=
vint
.
at
(
randomidx
);
vint
.
at
(
randomidx
)
=
temp
;
}
std
::
cout
<<
"vint = "
;
print_vec_int
(
vint
);
//*serazeni vektoru
std
::
sort
(
vint
.
begin
(),
vint
.
end
());
std
::
cout
<<
"vint = "
;
print_vec_int
(
vint
);
return
0
;
}
\ 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