7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
1/54
29/01/2013
1
Ae & aa
C++
LPRT : L1 : S1
Maa OULD BECHIR
Institut Universitaire Professionnel de Nouakchott
Ingnieur, consultant en EEI
2012/20131
A & aa C++: LPRT : S1M. OULD BECHIR: bc@a.
C
I
L
L/E
L : &
L
L
L , L
L
L
Institut Universitaire Professionnel de Nouakchott
2A & aa C++ : LPRT : S1,M. OULD BECHIR
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
2/54
29/01/2013
2
Institut Universitaire Professionnel de Nouakchott
D
Ve ae 26 ace(CM, TD e TP)C e de ea dbe e de cae ace
TD/TP e a de aa (DEV C++)Saed (1012) & Mad (1012)2 CC (6e eae, 9e eae) a e dce1 Eae a, a e dceNF=2/5 CC + 3/5 EF + PBReec de ae e ade cece
3A & aa C++ : LPRT : S1,M. OULD BECHIR
I
Institut Universitaire Professionnel de Nouakchott
4
I. D
Oe: aab d d d ad aa A Kaa (9
c), a ac a a caa
D #1 : dc, c cccd a
D #2: d a d b d a cacab a ac
D #2(P Rb): d a b d d,a d d d ca db bab
A & aa C++ : LPRT : S1,M. OULD BECHIR
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
3/54
29/01/2013
3
I
Institut Universitaire Professionnel de Nouakchott
5
II. Obec
Obec#1 : Ob d a ac a aa ac
Obec#2 : Aa ca
c
Obec #3 : d a !!!
A & aa C++ : LPRT : S1,M. OULD BECHIR
I
Institut Universitaire Professionnel de Nouakchott
6
III. EeeEee#1 : Ncda d ab
Eee#2 : a cda db db
Eee#3 : c a a
A & aa C++ : LPRT : S1,M. OULD BECHIR
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
4/54
29/01/2013
4
I
Institut Universitaire Professionnel de Nouakchott
7
IV. Pbae
#1 : Mda : d b
#2 : R : a
#3 :Ce: ac
Fae cec
dedae d
aae e de a ace
A & aa C++ : LPRT : S1,M. OULD BECHIR
I
Institut Universitaire Professionnel de Nouakchott
8
IV. Ce a ae b a
Cd#1 : I
Cd#2 : Md
Cd#3 : R
Ece e
ae
aee
A & aa C++ : LPRT : S1,M. OULD BECHIR
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
5/54
29/01/2013
5
I
Institut Universitaire Professionnel de Nouakchott
9
V. Eae de aa d a
Eae#1 : Dc d d
Eae#2 : Dc d a
Eae#4 : Ta d d
Eae#5 : Ed d a
Eae#3 : L d aab
Sa ee
ce ae
aa a a
de
ab
A & aa C++ : LPRT : S1,M. OULD BECHIR
I
Institut Universitaire Professionnel de Nouakchott
10
VI. U ee a
De : Le, Lae
Taee : Ae=LXLa
Ra : Acae dAe
Pbe : cace ae d ecae
::
D
E( )
L()
E( )
L()
S=LXL
E(L : S)
F
A & aa C++ : LPRT : S1,M. OULD BECHIR
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
6/54
29/01/2013
6
I C++
Institut Universitaire Professionnel de Nouakchott
11
Q : Q'e ce e c'e ae ae ?
R : adc da aae de aa d'
ae (cde)
Ma a ac cd a cd!!!
Pae ae
A & aa C++ : LPRT : S1,M. OULD BECHIR
I C++
Institut Universitaire Professionnel de Nouakchott
12
Q : Q'e ce e c'e aae de aa ?
R: Eebe de be e de e eea de
cbe ce be a de de de c dae
Laae de aa
R: cde edae ee e aae ace e e
aae eee(a)
A & aa C++ : LPRT : S1,M. OULD BECHIR
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
7/54
29/01/2013
7
I C++
Institut Universitaire Professionnel de Nouakchott
13
Scaa
Ae
c("M a)
Pae c da
aae (C++)
I a () C
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
8/54
29/01/2013
8
I C++
Institut Universitaire Professionnel de Nouakchott
15
Laae de ba e a ea Q: Pa a ?
000111001100110100011100101101001011
BAS NIVEAU
HAUT NIVEAU
ASSEMBLEUR
C
JAVA
RUBY
PYTHON
C# .NET
.
.
.
.
I(a==b)c
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
9/54
29/01/2013
9
I C++
Institut Universitaire Professionnel de Nouakchott
17
Ieac aec a ace HELLO WORLD
ETAPES:
1) Fae 'a
2) Ece e cde 'ade d' de de ee (Bc Ne, Nead) e eee
a a .c da ee a e
3) Ce e cde 'ade de De C++
4) Lace a ce e ece e .ee
# ;
()
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
10/54
29/01/2013
10
L
Institut Universitaire Professionnel de Nouakchott
19
N de aabe e de e
N#1 : b, a d,a a caaa b
N#2 :ac a d
N#3 : d d
d a a
N#4 : c a d d ac c d d
N#5 (TYPE) : Eb d ab a aab
VARIABLES : : TYPE
E : VARIABLES< , > :
N :
A & aa C++ : LPRT : S1,M. OULD BECHIR
L
Institut Universitaire Professionnel de Nouakchott
20
Le cae
U aab d a , a a a a d a a:Ca : 3,14O ac aa aab
Laeca
D: c a dac a aab d ac a a da aab d dE: 3,14
NMadBcP_VP_Aca
A & aa C++ : LPRT : S1,M. OULD BECHIR
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
11/54
29/01/2013
11
L
Institut Universitaire Professionnel de Nouakchott
21
Sce de de eae
R : a, dbE : B : bCaac : ca
I d aab, cac cd a aa db, caac, c . P c d b, d ac .
U d 1 8 c a
A & aa C++ : LPRT : S1,M. OULD BECHIR
L
Institut Universitaire Professionnel de Nouakchott
22
Le ae
Ae:
+ (add) (ac)X (ca)
/ (d)%(d): d a d
Le:
ET (&&)OU ()INVERSE ( !) LOGIQUE(c)
Caa: >, =,
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
12/54
29/01/2013
12
L
Institut Universitaire Professionnel de Nouakchott
23
La e de aabe
Variable locale : par rapport une portion de programme
Variable globale : par rapport tout le programme
Visibilit : incluse dans la porte (l o elle visible)
La portedun identificateur est la partie du programme dans laquellelidentificateur peut tre utilis sans provoquer de conflit (erreur decompilation)
Eee :
A & aa C++ : LPRT : S1,M. OULD BECHIR
L/E
Institut Universitaire Professionnel de Nouakchott
24
Lece :
La a d a acE: Sa( Q :? )
Cc a ca cda
Ece:
La ac a aE: Ac( d d : XXXUM)
A & aa C++ : LPRT : S1,M. OULD BECHIR
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
13/54
29/01/2013
13
L/E
Institut Universitaire Professionnel de Nouakchott
25
E:
Vaab : : //dcaaD
Ec(D c) //AcaL(Va) //SaEc(V a a :Va) //Aca
Va=VaX2 //TaEc(La a :Va) //AcaF
A & aa C++ : LPRT : S1,M. OULD BECHIR
L/E
Institut Universitaire Professionnel de Nouakchott
26
P
#
;
()
;
; ;
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
14/54
29/01/2013
14
L/E
Institut Universitaire Professionnel de Nouakchott
27
P
#
;
()
=3.14;
;
;
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
15/54
29/01/2013
15
L : &
Institut Universitaire Professionnel de Nouakchott
29
L : SI, ALORS, SINON, SELON QUE
E:Ca#2 : S a ee e ee 10 e ee 12, ace Paabe, ee ee
12 ace Me, ace Ia
V : :
A(E :)
L()
S >=12
A A(M)
S
S >=10
A(P)
F
S A(I)
F
A & aa C++ : LPRT : S1,M. OULD BECHIR
L : &
Institut Universitaire Professionnel de Nouakchott
L : SI, ALORS, SINON, SELON QUE
S
S
.
.
.
S
C : A(
!)
C : A( )
C : A( )
C : A( )C : A( )
P
A & aa C++ : LPRT : S1,M. OULD BECHIR
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
16/54
29/01/2013
16
L : &
Institut Universitaire Professionnel de Nouakchott
L : . C++Sce Sae e a Sae e C/C++
SI S a FSI I(cd ) c
SI, SINON S a SINONa FSI
I(cd) c c
SI, SINON SI S a SINONSI (cd) a FSI
I(cd) cE (cd) c
SELON Q UE S ca 1 : a ca 2:a
da: a
Sc(a)Ca 1: Ca 2:
Da:
Ta Ta < cd > a FTa
W(cd) c
R R Ta / c
Dc;W(cd);
P P a d< _> a a d a F
F(=1;
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
17/54
29/01/2013
17
L : &
Institut Universitaire Professionnel de Nouakchott
P
CC: ae e, e 'ae:1: Add de de be
2: Mca de de be
3: D de de be
4: Qe
#cde
aeaced;
a()
c;
a a,b,,,d;
c
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
18/54
29/01/2013
18
L : &
Institut Universitaire Professionnel de Nouakchott
P ()
cae 3:
c
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
19/54
29/01/2013
19
L : &
Institut Universitaire Professionnel de Nouakchott
L : TANT QUE, REPETER, POUR
TANT QUE : WHILE
A E : PGCD
V : :
Ac(D ad b d d : a)L(a)Ac(D b d d : b)
L(b)Ta a !=bS a
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
20/54
29/01/2013
20
L : &
Institut Universitaire Professionnel de Nouakchott
L : TANT QUE, REPETER, POUR
C : =TARZAN //
R
A(E :)
L( )T !=
Ace(Ve de ae e cec)
E
REPETER: DO WHILE
A & aa C++ : LPRT : S1,M. OULD BECHIR
L : &
Institut Universitaire Professionnel de Nouakchott
L : TANT QUE, REPETER, POUR
POUR: FOR
://
POUR
F P
Si le nombre ditrations est connu davance
On peut inverser le sens de parcours de la boucle
On peut modifier le pas de sa valeur par dfaut (1)
A
P =1 10 1
A( :)
F P
E
A & aa C++ : LPRT : S1,M. OULD BECHIR
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
21/54
29/01/2013
21
L : &
Institut Universitaire Professionnel de Nouakchott
L : SEMANTIQUE
(=1 ;
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
22/54
29/01/2013
22
L : &
Institut Universitaire Professionnel de Nouakchott
P :++ : cee e ee a ee ae (=+1)
++ : cee e ee acee ae (=(+1)1)
: dcee e ee a ee ae (=1)
: dcee e ee acee ae (=(1)+1)
(+,/,*) : adde de, e e : (=+, =/, =*)
Continue : provoque (dans une instruction do, for, ou while) larrt de litration couranteet le passage au dbut de litration suivante.
Break : provoque larrt de la premire instruction do, for, switch ou while englobant
C:
A & aa C++ : LPRT : S1,M. OULD BECHIR
L : &
Institut Universitaire Professionnel de Nouakchott
P
CC: U ae ace e ee de 0 10 e de ca
#cde
aeace d;
a()
ce=0;
c =10;
e(ce
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
23/54
29/01/2013
23
L : &
Institut Universitaire Professionnel de Nouakchott
P
CC: U ae ace e ee de 0 10 e de ca
#cde
aeace d;
a()
ce(0);
=10;
d
c
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
24/54
29/01/2013
24
L : &
Institut Universitaire Professionnel de Nouakchott
TD
1) Dee ecae
2) Facee
3) Mca Eee
4) PGCD
5) Tae de Paca
TD
A & aa C++ : LPRT : S1,M. OULD BECHIR
L : &
Institut Universitaire Professionnel de Nouakchott
TD
1) Dee ecae
TD
#cde
aeace d;
a()
ae, ae;
c > ae;
c > ae;
( e(0); e < ae; e++)
( ce(0); ce < ae; ce++)
c
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
25/54
29/01/2013
25
L : &
Institut Universitaire Professionnel de Nouakchott
TD
2) Facee
TD
#cde
aeace d;
a()
ea = 1;
;
c
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
26/54
29/01/2013
26
L : &
Institut Universitaire Professionnel de Nouakchott
TD
3) Mca Eee
TD
Pa de a a b
1 13 5
0 6 10
1 3 20
1 1 40
=5+20+40=65
A & aa C++ : LPRT : S1,M. OULD BECHIR
L : &
Institut Universitaire Professionnel de Nouakchott
TD
3) Mca Eee
TD
#cde
aeace d;
a()
a;
b;
e=0;
c
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
27/54
29/01/2013
27
L : &
Institut Universitaire Professionnel de Nouakchott
TD
4) PGCD
TD
: :
Ac(D ad b d d : a)L(a)Ac(D b d d : b)L(b)Ta a !=b
S a
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
28/54
29/01/2013
28
L : &
Institut Universitaire Professionnel de Nouakchott
TD
4) PGCD
TD
#cde
aeace d;
a()
a;
b;
c=0;
d=0;
c
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
29/54
29/01/2013
29
L : &
Institut Universitaire Professionnel de Nouakchott
TD
5)Tae de PASCAL
TD
)!)(1()!1(
)1(!
)!(!
!
knknkk
knn
knk
nC
k
n
+
+=
=
Ck
n
k
n
k
knC 1)1( +=
A & aa C++ : LPRT : S1,M. OULD BECHIR
L : &
Institut Universitaire Professionnel de Nouakchott
TD
5)Tae de PASCAL
TD
#cde
aeace d;
a()
, , , ;
c
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
30/54
29/01/2013
30
L : &
Institut Universitaire Professionnel de Nouakchott
TD
Fc aae
TD
#cde
//#cde // #cde
aeace d;
a()
a =10;
a c=();
a =e();
a =();
a =();
a =c();
a =a();
a =ac();
a =(,2);c
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
31/54
29/01/2013
31
L
Institut Universitaire Professionnel de Nouakchott
61
Tabea ae 1D/eae
R
P =0 ae1
Ac(E :+1 :)L()N[]
F
Tabea ae 1D/acae
P
P =0 ae1
Ac(N[])F
A & aa C++ : LPRT : S1,M. OULD BECHIR
L
Institut Universitaire Professionnel de Nouakchott
62
Tabea ae 1D/aa
Eee: cac de ee de e
I
Ne[4]=2,3,4,1 //N[0]=2, N[1]=3, N[2]=4, N[3]=1 Ne[4]=2,3 //N[0]=2, N[1]=3, N[2]=0, N[3]=0 Ne[4]=0 //N[0]=0, N[1]=0, N[2]=0, N[3]=0 Ne[4]=1 //N[0]=1, N[1]=0, N[2]=0, N[3]=0
Ec a dad a b d , a a a ac a a .
A & aa C++ : LPRT : S1,M. OULD BECHIR
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
32/54
29/01/2013
32
L
Institut Universitaire Professionnel de Nouakchott
63A & aa C++ : LPRT : S1,M. OULD BECHIR
TD
Eee: cac de ee de e
#
;
()
N=1; // I
[N];
(0);
(0);
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
33/54
29/01/2013
33
L
Institut Universitaire Professionnel de Nouakchott
65
Tabea dae 1D/ac
Tabea dae/cae a ae ae
O
Ne[]
C :
(3,2); // 3 2
.(8); //O 4 . C 8
.(); //O
C :
N.S()
A & aa C++ : LPRT : S1,M. OULD BECHIR
L
Institut Universitaire Professionnel de Nouakchott
66
Tabea dae 1D/caee de ae
A & aa C++ : LPRT : S1,M. OULD BECHIR
#
# //N !
;
()
; //U
._(12.5); //O
._(19.5);._(6);
._(12);
(0);
( (0);
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
34/54
29/01/2013
34
L
Institut Universitaire Professionnel de Nouakchott
67Paa & a :
LPRT : S4, M. OULD BECHIR
Tabea dee ND
T 2D
D : PE NOM
=5 ;
=4 ;
M [5][4]
00 01 02 03 04
10 11 12 13 14
20 21 22 23 2430 31 32 33 34
T ND
D : PE NOM .
=5 ;
=6 ;
.
= ;
G [5][6][]
L
Institut Universitaire Professionnel de Nouakchott
68Paa & a :
LPRT : S4, M. OULD BECHIR
Eee: Tabea dee 2D/eae
TD
#
;
[3][3] = 4, 3, 6,10, 0, 0,1, 5, 3;
()
( = 0; < 3; ++)
( = 0; < 3; ++)
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
35/54
29/01/2013
35
L
Institut Universitaire Professionnel de Nouakchott
69Paa & a :
LPRT : S4, M. OULD BECHIR
La Cae STRING
S A : C C = !!
D: #
S (M) ;
A :
N[0]=M
C :
S =+ +
: .()
L
Institut Universitaire Professionnel de Nouakchott
70Paa & a :
LPRT : S4, M. OULD BECHIR
La Cae STRING/Qee c#
#
;
()
1,2,3;
=E .;
_ ;
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
36/54
29/01/2013
36
L
Institut Universitaire Professionnel de Nouakchott
71
TD
TD
I abe[5];
Vec ab(5);
Tab.e();
EXERCICES:
1) Reae/Lece d abea2) Recece d da abea
3) Recece d a da abea
4) Recece d'e ae da abea
5) Taaa de Ga (A ae e )
A & aa C++ : LPRT : S1,M. OULD BECHIR
#cde
aeace d;
a() //eae a bce
abea[8]= 10, 4, 5, 2, 1, 7, 10, 3;
L
Institut Universitaire Professionnel de Nouakchott
72
TD
TD 1) Reae/Lece d abea 1D
A & aa C++ : LPRT : S1,M. OULD BECHIR
#
;
() // T
=0,;
[0];
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
37/54
29/01/2013
37
L
Institut Universitaire Professionnel de Nouakchott
73
TD
TD 2) Recece d da abea
A & aa C++ : LPRT : S1,M. OULD BECHIR
#
;
()
=0,;
[];
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
38/54
29/01/2013
38
L
Institut Universitaire Professionnel de Nouakchott
75
TD
TD 4) Recece de ae da abea
A & aa C++ : LPRT : S1,M. OULD BECHIR
#
;
N=5;
()
[N],,;
;
(=0;
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
39/54
29/01/2013
39
Institut Universitaire Professionnel de Nouakchott
77
L &
A & aa C++ : LPRT : S1,M. OULD BECHIR
* &U e e : *e;
*: eee 'adee e de a aabe Pe
&: de 'be a e e Rece
*A=NLL;
*B=NLL;
*C=NLL;
*D=NLL;
Iaa de e
La cae 0, 'ee a e e e ce adee dace cae
dbe *eA; //U e e ce 'adee d' be a e
ed *eB; //U e e ce 'adee d' be ee
*eC; //U e e ce 'adee d'e cae de caace
c *eD; //U e e ce 'adee d' be ee ca
Institut Universitaire Professionnel de Nouakchott
78
L &
A & aa C++ : LPRT : S1,M. OULD BECHIR
=2;
* (0); =&;
Me
61
96
2
C
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
40/54
29/01/2013
40
Institut Universitaire Professionnel de Nouakchott
79
L &
A & aa C++ : LPRT : S1,M. OULD BECHIR
Dee 2
C
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
41/54
29/01/2013
41
Institut Universitaire Professionnel de Nouakchott
81
L &
A & aa C++ : LPRT : S1,M. OULD BECHIR
Eecce: Le abea e e e
2) Dcaa d' abea e acae de e e 'ade de e
U aba d aab d , da ac c : ab[4]=2,3,6,0
Ad Vaab
02230
02234
02238
0223c
2
3
6
0
#cde
aeace d;
a()
ab[4]=2,3,6,0;
c
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
42/54
29/01/2013
42
Institut Universitaire Professionnel de Nouakchott
83
L &
A & aa C++ : LPRT : S1,M. OULD BECHIR
Dcaa
D /:
( )
C
; ; //
}
: ( )
L :1 1, . .
Institut Universitaire Professionnel de Nouakchott
84
L &
A & aa C++ : LPRT : S1,M. OULD BECHIR
Eee
int max(int a,int b) //fonction{int res=b ;if (a>b) res = a ;return res ;}
void permut(inta, int b) //procdure{int aux = b ;b = a ;a = a u x ; }
A :
( )
()
=5 ; =6 :
( ;) ;
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
43/54
29/01/2013
43
Institut Universitaire Professionnel de Nouakchott
85
L &
A & aa C++ : LPRT : S1,M. OULD BECHIR
Paae de aaeL aa d aa c/cd, a a a ac
Pa da, aa d c a a cede aed aa .Eee :
( , )
= ;
= ;
= ; //
()
, ;
=3 ;
=2 ;
(,) ;
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
44/54
29/01/2013
44
Institut Universitaire Professionnel de Nouakchott
87
L &
A & aa C++ : LPRT : S1,M. OULD BECHIR
Paae de aae
I / :
L aa a c cac aaa a ca a c d a ca ad d a c ac. C aa d ba
c d a a d c
Institut Universitaire Professionnel de Nouakchott
88
L &
A & aa C++ : LPRT : S1,M. OULD BECHIR
Paae de aae/eae e ac d abea a e#
;
RT( , *)
;
;
(=0;
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
45/54
29/01/2013
45
Institut Universitaire Professionnel de Nouakchott
89
L &
A & aa C++ : LPRT : S1,M. OULD BECHIR
P de c
Une fonction ne renvoie quun seul rsultat au plus Une fonction ne peut pas renvoyer de tableau statique Dans le cas de plus dun rsultat, on peut placer le rsultatdans un tableau dynamique
Une fonction peut galement renvoyer un pointeur commersultat Une fonction peut galement utiliser des variables globales Les procdures (fonction void) sont pratiques pour
rcuprer plus dun rsultat Un tableau nest jamais pass une fonction par rfrence Un tableau est pass une fonction en pointeur
Institut Universitaire Professionnel de Nouakchott
90
L
A & aa C++ : LPRT : S1,M. OULD BECHIR
D :
U c c c a .F(F())
D :
Ca c c d c bc dc a
da da a c
M :
P c c c, a :Identifier les cas particuliers
Identifier la condition darrt de la boucle
Identifier le cas gnral (gnrique)
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
46/54
29/01/2013
46
Institut Universitaire Professionnel de Nouakchott
91
L
A & aa C++ : LPRT : S1,M. OULD BECHIR
F:
F( ) // AEC NE BOCLE
{ = 1;
( = 1;
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
47/54
29/01/2013
47
Institut Universitaire Professionnel de Nouakchott
93
L
A & aa C++ : LPRT : S1,M. OULD BECHIR
T bePce:
Sece e d abea e aca e abea de a a db e
e caea ce d'e cc d .
A.:
aabe: ; , , Tabea T
P =0 1 ae
P =1 +1 ae
(T[]
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
48/54
29/01/2013
48
Institut Universitaire Professionnel de Nouakchott
95
L
A & aa C++ : LPRT : S1,M. OULD BECHIR
T bePae
#
;
()
[] = 10, 4, 5, 2, 1, 7, 10, 3;
= () / ();
= 0;
( = 0; =+1; )
([] < [1])
= [];
[] = [1];
[1] = ;
//() //
//
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
49/54
29/01/2013
49
Institut Universitaire Professionnel de Nouakchott
97
L
A & aa C++ : LPRT : S1,M. OULD BECHIR
T a ecEee
T=5, 10, 3, 12
=1 5, 10, 3, 12
=010, 5, 3, 12
=110, 5, 3, 12
=210, 5, 12, 3
=2 10, 5, 12, 3
=010, 5, 12, 3
=110, 12 , 5, 3
=210, 12, 5, 3
=3 10, 12, 5, 3
=012, 10, 5, 3
=112, 10 , 5, 3
=212, 10, 5, 3
Ce: Nb d'a ( d ca)
Nb d a:(1)
C: O(2)
Institut Universitaire Professionnel de Nouakchott
98
L
A & aa C++ : LPRT : S1,M. OULD BECHIR
T a ecPae
#
U ;
()
[] = 10, 4, 5, 2, 1, 7, 10, 3;
= () / ();
= 0;
( = 1;
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
50/54
29/01/2013
50
Institut Universitaire Professionnel de Nouakchott
99
L
A & aa C++ : LPRT : S1,M. OULD BECHIR
T a ccePce
P e ace de, ece 'e d e .
De ce a, ac a abea de ace de, e cae
e e e e e da e abea d
A.:
I dce( T[], a, beee)aabe: , dceRecece
dceRecece=aP =a+1 beee
T[]
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
51/54
29/01/2013
51
Institut Universitaire Professionnel de Nouakchott
101
L
A & aa C++ : LPRT : S1,M. OULD BECHIR
T ade (): cPce
C e d abea ae, Ode e e d abea a a a Aee cee e e ae d abea ace e de d .
A.:Vaabe : , , , abea T
Pcde TRade( T[]; ace; de)
Db
=ace;
=de;
=T[(+)/2];
Re a e T[] ae =1 F
(
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
52/54
29/01/2013
52
Institut Universitaire Professionnel de Nouakchott
103
A !!!
A & aa C++ : LPRT : S1,M. OULD BECHIR
1) T de Ha
Sc: Rc: Nca D, INSA d R
Institut Universitaire Professionnel de Nouakchott
104
A !!!
A & aa C++ : LPRT : S1,M. OULD BECHIR
2) Recece dce
M d'e ec, e ce e de
Pce:
I a e e be d ca de ecece, e e e ece e '
be de ae e caa eae 'de da a ece
Eee:
Recece d' e da abea :
) O ce e abea e de
) O ee a ecece a ae e e 'e
) E a de e
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
53/54
29/01/2013
53
Institut Universitaire Professionnel de Nouakchott
105
A !!!
A & aa C++ : LPRT : S1,M. OULD BECHIR
3) Ae de F: ae d cece
Institut Universitaire Professionnel de Nouakchott
106
A !!!
A & aa C++ : LPRT : S1,M. OULD BECHIR
4) Pbe d'Ee:5 He, 5 a, 5 e
O a c a a d c d.Da ca a d aa d.Ca b b d.Ca d ca d.Ca aa d.I a .I :
1) L'aa da a a 2) L d d c
3) L da b d .4) La a ac d a a bac.5) L a d a a b d ca.6) L d Pa Ma d a.7) L a d a a a d D.8) L' da a a d c b d a.9) L da a a.10) L' d Bd c d c d ca.11) L' d ca c d d D.12) L' d B Ma b d a b.13) L'aad d Pc.14) L c d a a b.15) L' d Bd a b d 'a.
7/24/2019 Algorithmique_programmationC++_Cours complet 2012-2013
54/54
29/01/2013
Institut Universitaire Professionnel de Nouakchott
107
R
A & aa C++ : LPRT : S1,M. OULD BECHIR
Se d e: .ede.cC d'ae : Ce Rbade, INSA de LLe ae de : Nca Deee, Mce Maead, INSAENSICAENAe e aa: Aad Gec, IUT BeMbadC de C++: Fa Lae, ENS CacaEecce c: Pa 13Ae e C: Jea Mce L, PEARSON, ISBN: 9782744074790, ISSN:17687616