-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
298 lines (269 loc) · 5.57 KB
/
main.c
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#include <stdio.h>
#include <stdio_ext.h>
#include <stdlib.h>
#include <string.h>
struct compte{
char nom[10];
char prenom[10];
char cin[10];
float montant;
};
struct compte comptes[1000];
void add();
void fidelisation();
void operations();
void retrait(int nb);
void depot(int nb);
void search();
void retour();
void Menu();
void searchCIN();
void afficheAscendant();
void afficheDescendant();
//ncc compteur des comptes sur l app
//nNcc nombre des nouveau comptes a creer
int ncc=0,nNcc;
int main()
{
Menu();
}
void affichSUP(){
int i,j;
float A;
printf("Entrer un Montant ");
scanf("%f",&A);
struct compte t;
for (i=0;i<ncc;i++){
for(j=0;j<ncc-i-1;j++){
if(comptes[j].montant>comptes[j+1].montant){
t=comptes[j];
comptes[j]=comptes[j+1];
comptes[j+1]=t;
}
}
}
for (i = 0; i <= ncc ; i++) {
if (comptes[i].montant>A)
printf("les comptes des client est %s %s %s %lf \n \n ",comptes[i].nom,comptes[i].prenom,comptes[i].cin,comptes[i].montant);
}
}
void affichINF(){
int i,j;
float A;
printf("Entrer un Montant ");
scanf("%f",&A);
struct compte t;
for (i=0;i<ncc;i++){
for(j=0;j<ncc-i-1;j++){
if(comptes[j].montant<comptes[j+1].montant){
t=comptes[j];
comptes[j]=comptes[j+1];
comptes[j+1]=t;
}
}
}
for (i = 0; i <= ncc ; i++) {
if (comptes[i].montant>A)
printf("les comptes des client est %s %s %s %lf \n \n ",comptes[i].nom,comptes[i].prenom,comptes[i].cin,comptes[i].montant);
}
}
void add()
{
printf("entrer your name :");
scanf("%s",comptes[ncc].nom);
__fpurge(stdin);
printf("entrer your first name :");
scanf("%s",comptes[ncc].prenom);
__fpurge(stdin);
printf("entrer your CIN :");
scanf("%s",comptes[ncc].cin);
__fpurge(stdin);
printf("entrer your montant");
scanf("%f",&comptes[ncc].montant);
__fpurge(stdin);
ncc++;
}
void operations(){
char cin1[10];
int i,choix,pos;
printf("Entrer le CIN que vous chercher");
scanf("%s",cin1);
for(i=0;i<ncc;i++){
if(strcmp(cin1,comptes[i].cin)==0)
{
printf("le montant cherchee est %f",comptes[i].montant);
pos=i;
}
}
printf("Choisir une operation : 1-retrait 2-depot");
scanf("%d",&choix);
if(choix == 1)
retrait(pos);
else if(choix == 2)
depot(pos);
else
printf("entrer 1 ou 2!!!");
}
void searchCIN(){
char cin2[10];
int i,pos;
printf("Entrer le CIN de compte que vous chercher");
scanf("%s",cin2);
for(i=0;i<ncc;i++){
if(strcmp(cin2,comptes[i].cin)==0)
{
printf("le compte cherchee est :\n Nom : %s Prenom : %s\n CIN : %s Montant : %f\n", comptes[pos].nom,comptes[pos].prenom,comptes[pos].cin,&comptes[pos].montant);
break;
}
}
}
void retrait(int nb){
float somme;
printf("Entrer la somme que vous voulez retrait");
scanf("%f",&somme);
if(somme <= comptes[nb].montant){
printf("le montant apres le retrait est : %f",comptes[nb].montant -= somme);
}
else
printf("votre solde est insuffisant");
}
void depot(int nb)
{
float somme;
printf("Entrer la somme que vous voulez depose");
scanf("%f",&somme);
comptes[nb].montant += somme;
printf("Votre montant est : %f",comptes[nb].montant);
}
void retour(){
int c;
printf("1:retour au menu\n 2: sortir du programme\n");
scanf("%d",&c);
switch(c){
case 1:
Menu();
break;
default :
printf("vous avez quitter le programme");
}
}
void aff(){
int nb;
printf("Afficher par :\n1-Ordre ascendant\n2-Ordre Descendant\n3-Ordre ascendant 2\n4-Ordre descendant 2\n4-Recherche CIN\n");
scanf("%d",&nb);
switch(nb){
case 1:
afficheAscendant();
retour();
break;
case 2:
afficheDescendant();
retour();
break;
case 3:
affichSUP();
retour();
break;
case 4:
affichINF();
retour();
break;
case 5:
searchCIN();
retour();
break;
}
}
void Menu(){
int i;
int choix;
printf(" Menu \n");
printf("0-Quitter\n1-Cree un compte\n2-Cree plusieur comptes\n3-Operations\n4-Affichage\n5-Fidelisation");
scanf("%d",&choix);
switch(choix)
{
case 0:
exit(1);
case 1:
add();
retour();
break;
case 2:
printf("combien de comptes vous voulez cree?");
scanf("%d",&nNcc);
i=0;
while(i<nNcc){
add();
i++;
system("clear");
}
retour();
break;
case 3:
operations();
retour();
break;
case 4:
aff();
retour();
break;
case 5:
fidelisation();
retour();
break;
}
}
void afficheDescendant()
{
int i,k;
struct compte t;
for (i=0;i<ncc;i++){
for(k=1;k<ncc-i-1;k++){
if(comptes[k - 1].montant<comptes[k].montant)
{
t=comptes[k];
comptes[k]=comptes[k-1];
comptes[k-1]=t;
}
}
}
for (i = 0; i < ncc ; i++) {
printf("le compte de client est:\n Nom : %s |Prenom : %s |CIN : %s |Montant : %f \n \n ",comptes[i].nom,comptes[i].prenom,comptes[i].cin,comptes[i].montant);
}
}
void fidelisation(){
int i,k,j;
struct compte t;
for (i=0;i<ncc;i++){
for(k=0;k<ncc-i-1;k++){
if(comptes[k].montant<comptes[k+1].montant)
{
t=comptes[k];
comptes[k]=comptes[k+1];
comptes[k+1]=t;
}
}
}
for(j=0;j<3;j++){
comptes[j].montant= comptes[j].montant + (comptes[j].montant*0.013);
printf("le nouveau montant du compte numero %d est : %f ",j+1,comptes[j].montant);
}
}
void afficheAscendant()
{
int i,k;
struct compte t;
for (i=0;i<ncc;i++){
for(k=1;k<=ncc-i-1;k++){
if(comptes[k-1].montant>comptes[k].montant)
{
t=comptes[k-1];
comptes[k-1]=comptes[k];
comptes[k]=t;
}
}
}
for (i = 0; i < ncc ; i++) {
printf("le compte de client est:\n Nom : %s |Prenom : %s |CIN : %s |Montant : %f \n \n ",comptes[i].nom,comptes[i].prenom,comptes[i].cin,comptes[i].montant);
}
}