Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102805558
loops.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Feb 24, 08:54
Size
631 B
Mime Type
text/x-c
Expires
Wed, Feb 26, 08:54 (2 d)
Engine
blob
Format
Raw Data
Handle
24429573
Attached To
R7571 SP4E-TB-TL-FR
loops.cpp
View Options
#include <array>
#include <vector>
int
main
()
{
std
::
vector
<
int
>
vec
(
10
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
vec
[
i
]
=
10
;
}
std
::
array
<
int
,
10
>
array
;
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
array
[
i
]
=
10
;
}
{
// vector loop with iterators
std
::
vector
<
int
>::
iterator
it
=
vec
.
begin
();
std
::
vector
<
int
>::
iterator
end
=
vec
.
end
();
for
(;
it
!=
end
;
++
it
)
{
*
it
=
10.
;
}
}
{
// with the auto
auto
it
=
vec
.
begin
();
auto
end
=
vec
.
end
();
for
(;
it
!=
end
;
++
it
)
{
*
it
=
10.
;
}
}
{
// with the range loop
for
(
auto
&
v
:
vec
)
{
v
=
10.
;
}
}
}
Event Timeline
Log In to Comment