-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorrection algorithme bancaire.txt
More file actions
167 lines (143 loc) · 11.8 KB
/
Copy pathcorrection algorithme bancaire.txt
File metadata and controls
167 lines (143 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
┌──────────────────────────────────────────────────────────────────┐
│ TDNT (Table de déclaration nouveaux types) │
├──────────────────────────────────────────────────────────────────┤
│ tab1 : tableau de 10 chaînes │
│ │
│ tab2 : tableau de 10 chaînes │
│ │
└──────────────────────────────────────────────────────────────────┘
TDOG
┌──────────────────────────────────────────────────────────┐
│ Objet │ Nature / Type │
├──────────────────────────────────────────────────────────┤
│ t │ tab1 │
├──────────────────────────────────────────────────────────┤
│ carte │ tab2 │
├──────────────────────────────────────────────────────────┤
│ n │ entier │
└──────────────────────────────────────────────────────────┘
Algorithme Problème_Cartes
début
saisir(n,1,10)
remplir(t, n)
former(carte, t, n)
affichage(carte, n)
fin
TDOG
┌──────────────────────────────────────────────────────────┐
│ Objet │ Nature / Type │
├──────────────────────────────────────────────────────────┤
│ t │ Tab14 │
├──────────────────────────────────────────────────────────┤
│ carte │ Tab15 │
├──────────────────────────────────────────────────────────┤
│ n │ entier │
├──────────────────────────────────────────────────────────┤
│ saisir,remplir,former │ procédure │
│ affichage │ │
└──────────────────────────────────────────────────────────┘
procédure saisir(@n:entier,min,max)
début
répéter
écrire("Donner la taille du tableau (entre ", min, " et ", max, ") = ")
lire(n)
jusqu'à (min ≤ n) ET (n ≤ max)
fin
fonction verif(ch : chaîne):booléen
début
i ← 0
valide ← VRAI
tant que (i < long(ch)) ET (valide = VRAI) faire
si non("0" ≤ ch[i] ≤ "9") alors
valide ← FAUX
sinon
i ← i + 1
fin si
fin tant que
retourner valide
fin
TDOL
┌──────────────────────────────────────────────────────────┐
│ Objet │ Nature / Type │
├──────────────────────────────────────────────────────────┤
│ i │ entier │
└──────────────────────────────────────────────────────────┘
| valider | booléen |
procédure remplir(@t : tab1; n : entier)
début
pour i de 0 à n-1 faire
répéter
lire(t[i])
jusqu'à (verif(t[i]) = VRAI) ET (long(t[i]) = 14)
fin pour
fin
TDOL
┌──────────────────────────────────────────────────────────┐
│ Objet │ Nature / Type │
├──────────────────────────────────────────────────────────┤
│ i │ entier │
└──────────────────────────────────────────────────────────┘
procédure former(@dest : tab2, src : tab1, n : entier)
début
pour i de 0 à n-1 faire
dest[i] ← src[i] + calcul(src[i])
fin pour
fin
TDOL
┌──────────────────────────────────────────────────────────┐
│ Objet │ Nature / Type │
├──────────────────────────────────────────────────────────┤
│ i │ entier │
└──────────────────────────────────────────────────────────┘
| calcul |fonction |
fonction calcul(ch1 : chaîne):entier
début
ch ← inverse(ch1)
total ← 0
pour i de 0 à long(ch)-1 faire
digit ← entier(ch[i])
si i mod 2 = 0 alors
dbl ← digit * 2
si dbl > 9 alors
total ← total + (dbl div 10) + (dbl mod 10)
sinon
total ← total + dbl
fin si
sinon
total ← total + digit
fin si
fin pour
controle ← (10 - (total mod 10)) mod 10
retourner controle
fin
TDOL
┌──────────────────────────────────────────────────────────┐
│ Objet │ Nature / Type │
├──────────────────────────────────────────────────────────┤
│ ch, total, i, digit, dbl, controle │ entier │
└──────────────────────────────────────────────────────────┘
fonction inverse(ch : chaîne):chaîne
début
ch0 ← ""
pour i de 0 à long(ch)-1 faire
ch0 ← ch[i] + ch0
fin pour
retourner ch0
fin TDOL
┌──────────────────────────────────────────────────────────┐
│ Objet │ Nature / Type │
├──────────────────────────────────────────────────────────┤
│ ch0, i │ chaîne, entier │
└──────────────────────────────────────────────────────────┘
procédure affichage(t : tab2 ; n : entier)
début
pour i de 0 à n-1 faire
écrire(t[i])
fin pour
fin
TDOL
┌──────────────────────────────────────────────────────────┐
│ Objet │ Nature / Type │
├──────────────────────────────────────────────────────────┤
│ i │ entier │
└──────────────────────────────────────────────────────────┘