!
"
for (int i=0; i<n; ++i) {...}
#$%
%
! ! &
' ( $
)
*
"+
"
," -.. / % %0
% 1( *
"
*
"
&
' (
1( (2
*
" )
3
& 1!
! *
"
"
% "
8
1
7
*
"
4
:
9
*
"
"
% "
*
"
;
= $*
"
<<
8>
>
>
3
& 1!
! *
"
"
% "
5
6*
"
<7
<:
<9
8
>
>
>
7
:
"
4
9
2*
"
"
% "
*
"
;
"
<<
5
6*
"
<7
<:
<9
3
& 1!
! *
"
"
% "
8 7
1
4
:
*
"
"
% "
*
"
9
*
"
3
<<
= $*
"
& 1!
! *
"
"
% "
5
6*
"
<7
<9
8 7
7>
>
>
%4
%
4
"
% "
*
"
*
" 3
%
:
9
1 *
"
(
"
% "
*
"
<<
5
6*
"
<7
<9
! !
% "
%( %
4
"
0
3
& 1!
! *
"
"
% "
3
4
int main()
{
// definition and initialization: provides us with
// Booleans crossed_out[0],..., crossed_out[999]
bool crossed_out[1000];
for (unsigned int i = 0; i < 1000; ++i)
crossed_out[i] = false;
5
6*
"
"
,
1!
' *
"
% "
5 <AAA
crossed_out[i] !
! *
"
*
" 3
// computation and output
std::cout << "Prime numbers in {2,...,999}:\n";
for (unsigned int i = 2; i < 1000; ++i)
if (!crossed_out[i]) {
// i is prime
std::cout << i << " ";
// cross out all proper multiples of i
for (unsigned int m = 2*i; m < 1000; m += i)
crossed_out[m] = true;
}
std::cout << "\n";
@
@
@
?
return 0;
}
! ?
& 1! "
2*
"
*
"
"i
!
*
" = $*
"
+
3
*
"
% "+
*
"
i
& $
! E
2
!
&
B C
(D
!
*
"
! ) %(
>
'>E
"
*F
!
*
"
@
! 32
int main()
{
// input of n
std::cout << “Compute prime numbers in [2, n) for n = ?”;
unsigned int n;
std::cin >> n;
!E
2
=
!
// definition and initialization: provides us with
// Booleans crossed_out[0],..., crossed_out[n-1]
bool crossed_out[n]; // Fehler!
...
(
' ( :
(
bool crossed_out[1000]
! E
2
*
"
}
@
int a[5];
! 32
int main()
{
// input of n
std::cout << “Compute prime numbers in [2, n) for n = ?”;
unsigned int n;
std::cin >> n;
"
4 2
$
&
:4 %
3
a! !
(2
! %%
int a[5] = {4, 3, 5, 2, 1};
*
" FE
2
// definition and initialization: provides us with
// Booleans crossed_out[0],..., crossed_out[n-1]
bool* crossed_out = new bool[n]; // ok!
...
}
*?
& :4 %
%
a3
3
?
int a[] = {4, 3, 5, 2, 1};
"$
H
1( *"
4
%%
!
"2
1( *" !
% **
& E
*"
' (
$
$
B C
( D
% G4 %
"
(
4%
1( *"
!
H
*"
2"
$
$
B<D
B8D
"$
% **
I
!A
H
B7D
$
$
% **
& &
B C
( D
%(
C
(
C
( #(
%
&$
(
B C
( D
&
"
BD 1 !
$
$ 3
% (
BAD
"$
"
" ! *"
, B C( D
%
( 0
"$
H
$$
"$
% **
"$
H
$$
"
$$
% **
$$
"$
H
(
!
"
1( *"
$
!
H
1( *"
$
BD
*"
% **
! ! *"
*"
%
"
int a[5] = {4,3,5,2,1};
int b[5];
C%
b = a;
AJ 5
+
$
$
%%
?
!
*" 3 !
3
(
+%
$$
"%
(.
$$
& E
2
! $
3
3
>
"
(
1( *"
"$
$$
$
// Fehler!
int c[5] = a; // Fehler!
%@
BD
*"
! ! *"
"
4
!
&
,
4!
0 1( *" 1*" ( %
,
%
*"0
!
?
4%
! %!
! %
+3
%
H
% **
K 3
4%
(
#!
+!
*"
-
+
>
>
>
#!
>
>
>
*"
( *"
#!
) ( (2 >
>
>
3
( *"
!
+!
>
'>
" ! 3"$
$
$ B
AD
+B
<D
+
>
>
>
+B <D
int a[5] = {4,3,5,2,1};
int b[5];
b = a; // wieviele Elemente haben a und b nochmal?
*" 3 " $
*" 3 " $
$
$
$
$
for (unsigned int i = 0; i < 1000; ++i)
crossed_out[i] = false;
for (unsigned int i = 0; i < 1000; ++i)
crossed_out[i] = false;
'
'
*"
$
3
(
A
*"
$
3
(.
crossed_out
;;;
A
crossed_out
;;;
*" 3 " $
*" 3 " $
$$
$$
for (unsigned int i = 0; i < 1000; ++i)
crossed_out[i] = false;
for (unsigned int i = 0; i < 1000; ++i)
crossed_out[i] = false;
'
'
*"
$3
(.;;;
*"
$3
(.
%
(
A
;;;
crossed_out
4$$
*"
A
;;;
crossed_out
4$$
*"
*"
bool* begin = crossed_out;
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
// in the loop, pointer p successively points to all elements
for (bool* p = begin; p != end; ++p)
"
( (. (.8
A
2*"
%
%
4
crossed_out
*p = false; // *p is the element pointed to by p
(.;;;
;;;
(
%
A
crossed_out
"
.
;;;
4$$
*"
' *"
>
*"
bool* begin = crossed_out;
2 ?
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
// in the loop, pointer p successively points to all elements
*"
for (bool* p = begin; p != end; ++p)
3
*p = false; // *p is the element pointed to by p
(
%
A
crossed_out
"
.
"$
$$
*"
"$
$$ ' *"
(( ' *"
$$ ' *"
(( ' *"
$$ ' *"
>
>
>
6
$$
$ 1>
<
*"
$$ ' *" $ 1>
<
!2
%
!2
%
!2
%
!2
%
>
>
>
$ 1>
87
$ 1>
G:
;;;
(
!
H *"
#(
=
H( 2
%
!
% 2*"
, "
0
% = *"
3
*"
%
%% !
L
( *" ,
$
(
4 %
!%
%
L"
#!
*
%
*"
(
%
(
L"
,
=
(
$
(
$
! !
E
#!
(
H
#!
+
$
*
"
!
ME
#!
iptr
int i = 5;
#!
% 1( *
"
)
%
$
$
!
(
E
*
"
#!
$
int j = *iptr; // j = 5
(
N
H
M
L
iptr
L
i
( int >
+
LH
int* iptr = &i;
%
<
(
#!
>
">*iptr
?
$
$
int i = 5;
i
int *iptr = &i
%(
( $
&
&
M
int* iptr = &i;
#!
E
6 *"
6
( *"
int* iptr;
"
O
+
+
// nicht initialisiert
...
int j = *iptr; // Objekt an "zufaelliger“ Adresse
// --> undefiniertes Verhalten
int* iptr = 0;
*" *"
% A
$
#!
3
// Nullzeiger
...
int j = *iptr;
// kein Objekt an dieser Adresse
// --> "sicherer” Laufzeitfehler
6
,
+
+
*" *"
% A
$
#!
3
P
0
%
!
L
( B D
*"
int* iptr = 0;
// Nullzeiger
...
if (iptr != 0) {
4
// so ist’s am besten
!
$
}
)
)
4%
CA
*
$
+
%
int j = *iptr;
...
(
3
% H *"
*"
%
(
!
*"
*"
4%
"
(2
"
>
,
0
' (
"%
"
{+, -}
begin
{==, !=, <, >, <=, >=}
int a[5];
-
int* begin = a;
a
2O
(
int a[5];
@
int* begin = &a[0];
6*
"
3
B
AD
+
"
2 *
" *
"
3
?
a[0]
a[1]
$
a[2]
"%
a[3]
%
a[4]
"%
"
{+, -}
"
{+, -}
{==, !=, <, >, <=, >=}
{==, !=, <, >, <=, >=}
-
"!
>
>
>
(
a[0]
a[1]
a[5]
$
"
(
%
( 8
( <
(
a[0]
a[1]
a[2]
( .<
% 4 !
' *
"
( .8 ( .7
"
a[2]
a[3]
a[4]
a[5]
a[3]
a[4]
a[5]
?
( .G
"%
"%
"
{+, -}
{==, !=, <, >, <=, >=}
{==, !=, <, >, <=, >=}
-
+= + -= +
!
!*
"
(
a[0]
a[1]
a[2]
a[3]
<=
*
"+ %
'
a[4]
a[5]
O
a[0]
<
a[1]
&
1!
"
{+, -}
a[0]
a[1]
I ( N8
a[3]
a[4]
a[5]
==
*
" <=
>=
*
" <
a[4]
a[5]
""
!
( #(
*
"
!
L
I O N7
a[3]
<
R
$
$
( I O N<
(
a[2]
a[2]
*
" ==
BC
( D
-
S
( == (Q <
!
{==, !=, <, >, <=, >=}
<
!=
++ + --
"%
O
"
{+, -}
a[0]
a[1]
' (
"
. C
(
a[2]
a[3]
a[4]
a[5]
C(
8
&
1 !
""
!
( #(
!
*
"
*
"
bool* begin = crossed_out;
$
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
// in the loop, pointer p successively points to all elements
BC
( D
for (bool* p = begin; p != end; ++p)
*p = false; // *p is the element pointed to by p
!
L
a[0]
a[1]
$
. C
(
a[2]
a[3]
*
"
begin
' (
"
a[4]
8
A
a[5]
crossed_out
*
"
bool* begin = crossed_out;
)
C(
;;;
*
"
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
bool* begin = crossed_out;
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
// in the loop, pointer p successively points to all elements
// in the loop, pointer p successively points to all elements
for (bool* p = begin; p != end; ++p)
for (bool* p = begin; p != end; ++p)
*p = false; // *p is the element pointed to by p
*p = false; // *p is the element pointed to by p
begin
A
*
"
)
.
"
crossed_out
end
;;;
begin
A
p
end
crossed_out
;;;
*"
bool* begin = crossed_out;
*"
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
bool* begin = crossed_out;
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
// in the loop, pointer p successively points to all elements
// in the loop, pointer p successively points to all elements
for (bool* p = begin; p != end; ++p)
for (bool* p = begin; p != end; ++p)
*p = false; // *p is the element pointed to by p
begin
=
p
*"
*p = false; // *p is the element pointed to by p
end
begin
p
&
$
+ 3
end
$
A
crossed_out
;;;
A
*"
bool* begin = crossed_out;
;;;
crossed_out
*"
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
bool* begin = crossed_out;
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
// in the loop, pointer p successively points to all elements
// in the loop, pointer p successively points to all elements
for (bool* p = begin; p != end; ++p)
for (bool* p = begin; p != end; ++p)
*p = false; // *p is the element pointed to by p
begin
p
%
*p = false; // *p is the element pointed to by p
end
$
A
begin
p
=
*"
end
$
crossed_out
;;;
A
crossed_out
;;;
*"
bool* begin = crossed_out;
*"
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
bool* begin = crossed_out;
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
// in the loop, pointer p successively points to all elements
// in the loop, pointer p successively points to all elements
for (bool* p = begin; p != end; ++p)
for (bool* p = begin; p != end; ++p)
*p = false; // *p is the element pointed to by p
*p = false; // *p is the element pointed to by p
begin
$
p
&
$
+ 3
end
$
begin
$
A
;;;
crossed_out
%
p
end
$
A
;;;
crossed_out
*"
bool* begin = crossed_out;
+ 3>
>
>
>
*"
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
bool* begin = crossed_out;
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
// in the loop, pointer p successively points to all elements
// in the loop, pointer p successively points to all elements
for (bool* p = begin; p != end; ++p)
for (bool* p = begin; p != end; ++p)
*p = false; // *p is the element pointed to by p
begin
$
A
$
p
$
$
>
>
> 3>
+
$
$
$
*p = false; // *p is the element pointed to by p
%
$
crossed_out
$
$
end
$
$
;;;
begin
$
A
$
=
p
$
$
$
$
$
$
crossed_out
*"
$
$
end
$
$
;;;
*"
bool* begin = crossed_out;
%
// pointer to first element
bool* end = crossed_out + 1000; // pointer after last element
// in the loop, pointer p successively points to all elements
for (bool* p = begin; p != end; ++p)
*p = false; // *p is the element pointed to by p
$
begin
$
$
$
$
A
&
$
$
$
$
?
$
end
$
$
3 ,
!
) %(
1!
4
%
?
1( *"
63
03 1( *" + !
*"
"
"!
@
"
% 4
! E
2
&
$
*"
*"
E !
( *" $
" $ 3"$
$
$
3 ! *"
$
%
! E
2
*">
>
>
"%
1
+
>
>
>! *"
;;;
crossed_out
% *"
$
@
!
new
*
B C
(D
*
(int+
3
3
new #(
4$
$
E
2
%
3 !
1( *"
%
( L
F C( *"
$
%
F
4%
(
*
&
T
T (
&
( ( *
" ! *
"+
%%
1( *
"
>
%
,
"
T
0
int* i = new int;
" (
% *
" 1( *
" 0
"
% *
" 1( *
"
int main()
{
// input
std::cout << "Compute prime numbers
in {2,...,n-1} for n =? ";
unsigned int n;
std::cin >> n;
0
1!
,
% *
" 1( *
" 0
4
"
% *
" 1( *
"
int main()
{
// input
std::cout << "Compute prime numbers
in {2,...,n-1} for n =? ";
unsigned int n;
std::cin >> n;
int main()
{
bool crossed_out[1000];
for (unsigned int i = 0; i < 1000; ++i)
crossed_out[i] = false;
bool* crossed_out = new bool[n];
for (unsigned int i = 0; i < n; ++i)
crossed_out[i] = false;
bool crossed_out[1000];
for (unsigned int i = 0; i < 1000; ++i)
crossed_out[i] = false;
bool* crossed_out = new bool[n];
for (unsigned int i = 0; i < n; ++i)
crossed_out[i] = false;
// computation and output
....
// computation and output
....
delete[] crossed_out;
// computation and output
....
// computation and output
....
delete[] crossed_out;
return 0;
}
%
,
"
" (
int* a = new int[3];
4
int main()
{
( ( *
" ! *
"+
%%
1( *
"
>
int* i = new int;
,
1!
T (
return 0;
return 0;
1!
( #(
$
crossed_out
}
}
!
*
"
% "!
% *
" 1( *
"
return 0;
}
&
*
#!
new
&
*
"!
% *" 1( *"
C
(
*" 3
! +!
#!
new
% *" 1( *"
C
(
*" 3
int* i = new int;
delete C
(
...
% ( L+
$
" % new !
F4$
$ 1( *"
$
#!
% T (3 3
$
! >
&
% *" 1( *"
H*"
!
% new
(
delete
int* a = new int[3];
! +!
>
int* a = new int[3];
delete[] C
(
delete i;
delete #(
"!
...
delete[] a;
% ( L+
" % new !
F4$
$ 1( *"
T (3 3
$
delete #(
&
% *" 1( *"
H*"
!
% new
(
delete
int* a = new int[3];
...
delete[] a;
$
$ %
! >
&
% *" 1( *"
H *"
% new
(
delete
!
6*" ! $
1( *"
$"
*
!
*" % "
$ !
1( *"
$ %T (
+
© Copyright 2026 Paperzz