Any suggestion about how to make the program better?

Any suggestions?
Build a detection model (and file and array storage by adding), and update (deposit and withdraw) time deposits from a certain number of depositors (up to 30).

The data for each depositor should have the following structure: Name, Address, M3 (amount, date), M6 (amount, date), M12 (amount, date) where the date indicates the last draw or deposit the current cash amount quarterly, six-month, and annual deposit.
The program also provides features for:
a) Entering and updating the annual interest rates for each term deposit.
b) Listing and reference for a depositor by name.
c) Recalculating deposits for the current date and displaying a full list of depositors with corresponding deposits, sorting in ascending order.

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
#include<iostream>
#include<cmath>
#define N 30 
using namespace std;

typedef struct{ 
char data[12];  
double suma;}
mesec;
typedef struct{ 
char ime[25];  
char adres[20]; 
 mesec M3,M6,M12;  
 double smetka;}
 vlojiteli;

 void input();
 void vnasqne();
 void teglene();
 void aktualizaciq();
 void spravka();
 void izvejdane();
 int menu();
 void disp();
 void load();
 void save();
 vlojiteli A[N];
 int top=0;
 
 int main()
 {
 int i;
 cout<<"\n Load from file";
 load();
 	do
{
    i=menu();
    	    switch(i)
    	    	{
    	    	    case 1:input();break;
    	    	    case 2:vnasqne();break;
    	    	    case 3:teglene();break;
    	    	    case 4:aktualizaciq();break;
    	    	    case 5:spravka();break;
    	    	    case 6:izvejdane();break;
    	    	    case 7:save();break;
    	    	}
}
			
			while(i!=8);}
			int menu()
                                    {
        	int ch;
  			cout<<" MENU"<<endl;
   			cout<<" 1.Vyvejdane \n"<<endl;
   			cout<<" 2.Vnasqne po smetka \n"<<endl;
   	   		cout<<" 3.Teglene ot smetka \n"<<endl;
   	     	cout<<" 4.Aktualizaciq na lihvi \n"<<endl;
   	     	cout<<" 5.Spravka za vlojitel po Ime \n "<<endl;
   	     	cout<<" 6.Izvejdane na vsichki vlojiteli sortirani v spisyk \n "<<endl;
   	     	cout<<" 7.Syhrani fail \n "<<endl;
   	     	cout<<" 8.Izhod \n "<<endl;
   	    do
        {
        cout<<"\n Izbor: ";
   cin>>ch;
      }
       while(ch<1||ch>8);
             return(ch);
             }
             
             void disp(int i)
             { 
             
                cout<<"\n Ime:"<<A[i].ime;
                cout<<"\n Adress:"<<A[i].adres;
                cout<<"\n M3 data:"<<A[i].M3.data<<"  M3 suma:"<<A[i].M3.suma<<endl;
                cout<<"\n M6 data:"<<A[i].M6.data<<"  M6 suma:"<<A[i].M6.suma<<endl;
                cout<<"\n M12 data:"<<A[i].M12.data<<"  M12 suma:"<<A[i].M12.suma<<endl;
                cout<<"\n Smetka:"<<A[i].smetka;}void input(){int i,n;do{cout<<"Broi vlojiteli:";
                cin>>n;
                            }
                            while (n<1||n>N);
                               fflush(stdin);
                               	for(i=top;i<top+n;i++)	{cout<<"nIme:";cin>>A[i].ime;
                               	cout<<"\n Adress:";cin>>A[i].adres;
                               	cout<<"\n M3 data:"; cin>>A[i].M3.data;
                               	cout<<"\n M3 suma:";
                               	cin>>A[i].M3.suma;
                               	A[i].smetka+=A[i].M3.suma;
                               	cout<<"\n M6 data:";
                               	cin>>A[i].M6.data;
                               	cout<<"\n M6 suma:";
                               	cin>>A[i].M6.suma;
                               	A[i].smetka+=A[i].M6.suma;
                               	cout<<"\n M12 data:";
                               	cin>>A[i].M12.data;
                               	cout<<"\n M12 suma:";
                               	cin>>A[i].M12.suma; A[i].smetka+=A[i].M12.suma;
                               			  	  	}
                               			  	  	top+=n;}void vnasqne(){int n,p,i;
                               			  	  	do{cout<<"\n Izberete nomer na vlojitel:";
                               			  	  	cin>>n;} while(n<1||n>N);
        										cout<<"\n Izberete vnoska za trimesechie,polovin godina ili edna godina:";
          										cin>>p;
												  	if(p==3)
													        for(i=n;i<n;i++)
           											{
													   cout<<"vyvedete data na vnasqne:";
           												cin>>A[i].M3.data;
           												cout<<"vyvedete suma na vnasqne:";
           												cin>>A[i].M3.suma;A[i].smetka+=A[i].M3.suma;
            										}
            					if(p==6)   
				   					for(i=n;i<n;i++)
                    {
                        cout<<"vyvedete data na vnasqne:";
cin>>A[i].M6.data;
cout<<"vyvedete suma na vnasqne:";
cin>>A[i].M6.suma;A[i].smetka+=A[i].M6.suma;
					}
	if(p==12)      for(i=n;i<n;i++)
        {
            cout<<"vyvedete data na vnasqne:";
cin>>A[i].M12.data;
cout<<"vyvedete suma na vnasqne:";
cin>>A[i].M12.suma;A[i].smetka+=A[i].M12.suma;
    	}
    	}
    	void teglene(){ int i,n;  double s;
    	do
            {cout<<"\n Izberete nomer na vlojitel:";
    	 cin>>n;
    	 }
    	 while(n<1||n>N);
cout<<"\n Izberete sumata,koqto iskate da izteglite:";
	cin>>s;
		for(i=n;i<n;i++)
                {
                    if(s<A[i].smetka)	A[i].smetka=A[i].smetka-s;

else cout<<"Nqmate tolkowa pari!";
}
}
void aktualizaciq()
{
    int n,i;
    double p;
    do
        {
            cout<<"\n Vyvedete srochen vlog,za koito iskate da promenite lihvata:";
cin>>n;
}
 while(n!=3 || n!= 6 || n!=12);
  cout<<"\n Vyvedete lihva v realno chislo:";
   cin>>p;
    for(i=0;i<N;i++)
        {
            	  if(n==3) A[i].M3.suma = A[i].M3.suma * p + A[i].M3.suma;
if(n==6) A[i].M6.suma = A[i].M6.suma * p + A[i].M6.suma;
if(n==12) A[i].M12.suma = A[i].M12.suma * p + A[i].M12.suma;
}
}
void spravka()
{
    int i; char n[15];
    cout<<"\n Vyvedi ime:";
    cin>>n;  for(i=0;i<N;i++)
    {
        if(A[i].ime==n) disp(i);
        }
        }
        void izvejdane()
        {
            int i,k,z; double temp;
            for(i=0;i<N;i++)
                for(z=i+1;z<N+1;z++)
                if(A[i].smetka>A[z].smetka)
                {
                    temp=A[i].smetka;
A[i].smetka=A[z].smetka;
A[z].smetka=temp;
}
for(i=0;i<N;i++)	disp(i);
}
void load()
{
        FILE *fp;    int i;
        if((fp=fopen("vlojiteli12.dat", "rb"))==NULL)
            {
            cout<<"\n EROR 404: File not found! ";
			return;
			}
if(fread(&top, sizeof(top), 1, fp)!=1)
    {
        cout<<"\n Error size"; exit(1);
	}
        	for(i=0;i<top;i++)
            if(fread(&A[i], sizeof(vlojiteli),1,fp)!=1)
            {
            cout<<"\n Error reading structure!"; exit(1);
			}
			}


void save()
{
    FILE *fp;
    int i;
    if((fp=fopen("vlojiteli12.dat", "wb"))==NULL)
        {
        cout<<"\n Error saving file!";
		return;
		}
if(fwrite(&top, sizeof(top), 1, fp)!=1)
    {
    cout<<"\n Error w top";
	exit(1);
	}
	for(i=0;i<top;i++)
    if(fwrite(&A[i], sizeof(vlojiteli),1,fp)!=1)
    {
        cout<<"\n Error writing str!";
exit(1);
}
fclose(fp);
}
Last edited on
12:17: error: expected initializer before 'A'

Line 12 is not a declaration of a function, nor is it a declaration of an array named A.

Note that global variables are bad news in general, and line 3 is too.

Instead of a #define use a const variable instead:

const int N = 30;

or better a constexpr:
constexpr int N = 30;

Today I have been watching videos from cppcon 2018. One of the things said was that C is part of C++ for backwards compatibility. In other words, one can #include C code from an old project and still compile it, but write the new code in C++.

With that in mind, the first thing to do would be to use a std::vector instead of an array, it's a shame a lot of teachers won't let their students do this.
Last edited on
So i have managed to get most of the things to work ,but from case 2 to case 5 i can't seem to make the program do something and i don't know why.Hope you have something that may help me.
Pick an indentation style (one that isn't chaotic) and stick to it.
https://en.wikipedia.org/wiki/Indentation_style

Okay here it is.Can you help me now? And hope you understand it.
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
#include<iostream>
#include<cmath>
#define N 30 
using namespace std;

 
typedef struct
{
  
char data[12];
   
double suma;
} 
mesec;

typedef struct
{
  
char ime[25];
   
char adres[20];
   
mesec M3, M6, M12;
   
double smetka;
} 
vlojiteli;

 
void input ();

void vnasqne ();

void teglene ();

void aktualizaciq ();

void spravka ();

void izvejdane ();

int menu ();

void disp ();

void load ();

void save ();

vlojiteli A[N];

int top = 0;

 
int
main () 
{
  
int i;
  
cout << "\n Load from file";
  
load ();
  
  do
    
    {
      
i = menu ();
      
switch (i)
	
	{
	
case 1:
	  input ();
	  break;
	
case 2:
	  vnasqne ();
	  break;
	
case 3:
	  teglene ();
	  break;
	
case 4:
	  aktualizaciq ();
	  break;
	
case 5:
	  spravka ();
	  break;
	
case 6:
	  izvejdane ();
	  break;
	
case 7:
	  save ();
	  break;
	
}
    
}
  
 
while (i != 8);
}


int
menu () 
{
  
int ch;
  
cout << " MENU" << endl;
  
cout << " 1.Vyvejdane \n" << endl;
  
cout << " 2.Vnasqne po smetka \n" << endl;
  
cout << " 3.Teglene ot smetka \n" << endl;
  
cout << " 4.Aktualizaciq na lihvi \n" << endl;
  
cout << " 5.Spravka za vlojitel po Ime \n " << endl;
  
cout << " 6.Izvejdane na vsichki vlojiteli sortirani v spisyk \n " << endl;
  
cout << " 7.Syhrani fail \n " << endl;
  
cout << " 8.Izhod \n " << endl;
  
  do
    
    {
      
cout << "\n Izbor: ";
      
cin >> ch;
    
}
  
while (ch < 1 || ch > 8);
  
return (ch);

}


 
void
disp (int i) 
{
  
 
cout << "\n Ime:" << A[i].ime;
  
cout << "\n Adress:" << A[i].adres;
  
cout << "\n M3 data:" << A[i].M3.data << "  M3 suma:" << A[i].M3.
    suma << endl;
  
cout << "\n M6 data:" << A[i].M6.data << "  M6 suma:" << A[i].M6.
    suma << endl;
  
cout << "\n M12 data:" << A[i].M12.data << "  M12 suma:" << A[i].M12.
    suma << endl;
  
cout << "\n Smetka:" << A[i].smetka;
} void

input ()
{
  int i, n;
  do
    {
      cout << "Broi vlojiteli:";
      
cin >> n;
    
}
  
while (n < 1 || n > N);
  
fflush (stdin);
  
for (i = top; i < top + n; i++)
    {
      cout << "nIme:";
      cin >> A[i].ime;
      
cout << "\n Adress:";
      cin >> A[i].adres;
      
cout << "\n M3 data:";
      cin >> A[i].M3.data;
      
cout << "\n M3 suma:";
      
cin >> A[i].M3.suma;
      
A[i].smetka += A[i].M3.suma;
      
cout << "\n M6 data:";
      
cin >> A[i].M6.data;
      
cout << "\n M6 suma:";
      
cin >> A[i].M6.suma;
      
A[i].smetka += A[i].M6.suma;
      
cout << "\n M12 data:";
      
cin >> A[i].M12.data;
      
cout << "\n M12 suma:";
      
cin >> A[i].M12.suma;
      A[i].smetka += A[i].M12.suma;
    
}
  
top += n;
}

void
vnasqne ()
{
  int n, p, i;
  
  do
    {
      cout << "\n Izberete nomer na vlojitel:";
      
cin >> n;
    }
  while (n < 1 || n > N);
  
cout <<
    "\n Izberete vnoska za trimesechie,polovin godina ili edna godina:";
  
cin >> p;
  
if (p == 3)
    
for (i = n; i < n; i++)
      
      {
	
cout << "vyvedete data na vnasqne:";
	
cin >> A[i].M3.data;
	
cout << "vyvedete suma na vnasqne:";
	
cin >> A[i].M3.suma;
	A[i].smetka += A[i].M3.suma;
      
}
  
if (p == 6)
    
for (i = n; i < n; i++)
      
      {
	
cout << "vyvedete data na vnasqne:";
	
cin >> A[i].M6.data;
	
cout << "vyvedete suma na vnasqne:";
	
cin >> A[i].M6.suma;
	A[i].smetka += A[i].M6.suma;
      
}
  
if (p == 12)
    for (i = n; i < n; i++)
      
      {
	
cout << "vyvedete data na vnasqne:";
	
cin >> A[i].M12.data;
	
cout << "vyvedete suma na vnasqne:";
	
cin >> A[i].M12.suma;
	A[i].smetka += A[i].M12.suma;
      
}

}


void
teglene ()
{
  int i, n;
  double s;
  
  do
    
    {
      cout << "\n Izberete nomer na vlojitel:";
      
cin >> n;
    
}
  
while (n < 1 || n > N);
  
cout << "\n Izberete sumata,koqto iskate da izteglite:";
  
cin >> s;
  
for (i = n; i < n; i++)
    
    {
      
if (s < A[i].smetka)
	A[i].smetka = A[i].smetka - s;
      
 
      else
	cout << "Nqmate tolkowa pari!";
    
}

}


void
aktualizaciq () 
{
  
int n, i;
  
double p;
  
  do
    
    {
      
cout <<
	"\n Vyvedete srochen vlog,za koito iskate da promenite lihvata:";
      
cin >> n;
    
}
  
while (n != 3 || n != 6 || n != 12);
  
cout << "\n Vyvedete lihva v realno chislo:";
  
cin >> p;
  
for (i = 0; i < N; i++)
    
    {
      
if (n == 3)
	A[i].M3.suma = A[i].M3.suma * p + A[i].M3.suma;
      
if (n == 6)
	A[i].M6.suma = A[i].M6.suma * p + A[i].M6.suma;
      
if (n == 12)
	A[i].M12.suma = A[i].M12.suma * p + A[i].M12.suma;
    
}

}


void
spravka () 
{
  
int i;
  char n[15];
  
cout << "\n Vyvedi ime:";
  
cin >> n;
  for (i = 0; i < N; i++)
    
    {
      
if (A[i].ime == n)
	disp (i);
    
}

}


void
izvejdane () 
{
  
int i, k, z;
  double temp;
  
for (i = 0; i < N; i++)
    
for (z = i + 1; z < N + 1; z++)
      
if (A[i].smetka > A[z].smetka)
	
	{
	  
temp = A[i].smetka;
	  
A[i].smetka = A[z].smetka;
	  
A[z].smetka = temp;
	
}
  
for (i = 0; i < N; i++)
    disp (i);

}


void
load () 
{
  
FILE * fp;
  int i;
  
if ((fp = fopen ("vlojiteli12.dat", "rb")) == NULL)
    
    {
      
cout << "\n EROR 404: File not found! ";
      
return;
    
}
  
if (fread (&top, sizeof (top), 1, fp) != 1)
    
    {
      
cout << "\n Error size";
      exit (1);
    
}
  
for (i = 0; i < top; i++)
    
if (fread (&A[i], sizeof (vlojiteli), 1, fp) != 1)
      
      {
	
cout << "\n Error reading structure!";
	exit (1);
      
}

}


 
 
void
save () 
{
  
FILE * fp;
  
int i;
  
if ((fp = fopen ("vlojiteli12.dat", "wb")) == NULL)
    
    {
      
cout << "\n Error saving file!";
      
return;
    
}
  
if (fwrite (&top, sizeof (top), 1, fp) != 1)
    
    {
      
cout << "\n Error w top";
      
exit (1);
    
}
  
for (i = 0; i < top; i++)
    
if (fwrite (&A[i], sizeof (vlojiteli), 1, fp) != 1)
      
      {
	
cout << "\n Error writing str!";
	
exit (1);
      
}
  
fclose (fp);

}
Hi, goshko1.
Perhaps the problem is your code is mainly a C code and this is a C++ forum. Many of our suggestions would change the face of your code.

To get a better help you could tell us:
- if this is an assignment (important!);
- if you have constrains (not to use std::vectors, keep the structs as they are, ...);
- if you know about std::strings, std::fstreams and std::vectors;
- if you know about classes and member functions (methods).

You could also provide a short example of the file "vlojiteli12.dat" to test your code.

What follows is another way to indent your code that could look more familiar to some of us.

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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#include <cmath>
#include <cstdio>       // <-- missing header
#include <iostream>


struct mesec {
    char data[12];
    double suma;
} ;


struct vlojiteli {
    char ime[25];
    char adres[20];
    mesec M3,
          M6,
          M12;
    double smetka;
} ;


void input ();
void vnasqne ();
void teglene ();
void aktualizaciq ();
void spravka ();
void izvejdane ();
int menu ();
void disp ();
void load ();
void save ();


constexpr int N { 30 };
vlojiteli A[N];
int top = 0;


int main ()
{
    int i;
    std::cout << "\nLoad from file";
    load ();
    do {
        i = menu ();
        switch (i)
        {
        case 1:
            input ();
            break;
        case 2:
            vnasqne ();
            break;
        case 3:
            teglene ();
            break;
        case 4:
            aktualizaciq ();
            break;
        case 5:
            spravka ();
            break;
        case 6:
            izvejdane ();
            break;
        case 7:
            save ();
            break;
        }
    } while (i != 8);
}


int menu ()
{
    int ch;
    std::cout << "MENU\n"
                 "1.Vyvejdane\n\n"
                 "2.Vnasqne po smetka\n\n"
                 "3.Teglene ot smetka\n\n"
                 "4.Aktualizaciq na lihvi\n\n"
                 "5.Spravka za vlojitel po Ime\n\n"
                 "6.Izvejdane na vsichki vlojiteli sortirani v spisyk\n\n"
                 "7.Syhrani fail\n\n"
                 "8.Izhod\n\n";
    do {
        std::cout << "\nIzbor: ";
        std::cin >> ch;
    } while (ch < 1 || ch > 8);
    return (ch);
}


void disp (int i)
{
    std::cout << "\nIme:" << A[i].ime
              << "\nAdress:" << A[i].adres
              << "\nM3 data:" << A[i].M3.data << "  M3 suma:" << A[i].M3.suma
              << "\nM6 data:" << A[i].M6.data << "  M6 suma:" << A[i].M6.suma
              << "\nM12 data:" << A[i].M12.data << "  M12 suma:" << A[i].M12.suma
              << "\nSmetka:" << A[i].smetka;
}


void input ()
{
    int i, n;
    do {
        std::cout << "Broi vlojiteli:";
        std::cin >> n;
    } while (n < 1 || n > N);

    fflush (stdin);

    for (i = top; i < top + n; ++i)
    {
        std::cout << "nIme:";
        std::cin >> A[i].ime;
        std::cout << "\nAdress:";
        std::cin >> A[i].adres;
        std::cout << "\nM3 data:";
        std::cin >> A[i].M3.data;
        std::cout << "\nM3 suma:";
        std::cin >> A[i].M3.suma;
        A[i].smetka += A[i].M3.suma;
        std::cout << "\nM6 data:";
        std::cin >> A[i].M6.data;
        std::cout << "\nM6 suma:";
        std::cin >> A[i].M6.suma;
        A[i].smetka += A[i].M6.suma;
        std::cout << "\nM12 data:";
        std::cin >> A[i].M12.data;
        std::cout << "\nM12 suma:";
        std::cin >> A[i].M12.suma;
        A[i].smetka += A[i].M12.suma;
    }
    top += n;
}


void vnasqne ()
{
    int n, p, i;
    do {
        std::cout << "\nIzberete nomer na vlojitel:";
        std::cin >> n;
    } while (n < 1 || n > N);

    std::cout << "\nIzberete vnoska za trimesechie,polovin godina ili edna godina:";
    std::cin >> p;
    if (p == 3)
    {
        for (i = n; i < n; ++i)
        {
            std::cout << "vyvedete data na vnasqne:";
            std::cin >> A[i].M3.data;
            std::cout << "vyvedete suma na vnasqne:";
            std::cin >> A[i].M3.suma;
            A[i].smetka += A[i].M3.suma;
        }
    }
    if (p == 6)
    {
        for (i = n; i < n; ++i)
        {
            std::cout << "vyvedete data na vnasqne:";
            std::cin >> A[i].M6.data;
            std::cout << "vyvedete suma na vnasqne:";
            std::cin >> A[i].M6.suma;
            A[i].smetka += A[i].M6.suma;
        }
    }
    if (p == 12)
    {
        for (i = n; i < n; ++i)
        {
            std::cout << "vyvedete data na vnasqne:";
            std::cin >> A[i].M12.data;
            std::cout << "vyvedete suma na vnasqne:";
            std::cin >> A[i].M12.suma;
            A[i].smetka += A[i].M12.suma;
        }
    }
}


void teglene ()
{
    int i, n;
    double s;
    do {
        std::cout << "\nIzberete nomer na vlojitel:";
        std::cin >> n;
    } while (n < 1 || n > N);

    std::cout << "\nIzberete sumata,koqto iskate da izteglite:";
    std::cin >> s;
    for (i = n; i < n; ++i)
    {
        if (s < A[i].smetka)
        {
            A[i].smetka = A[i].smetka - s;
        }
        else
        {
            std::cout << "Nqmate tolkowa pari!";
        }
    }
}


void aktualizaciq ()
{
    int n, i;
    double p;
    do {
        std::cout << "\nVyvedete srochen vlog,za koito iskate da promenite lihvata:";
        std::cin >> n;
    }  while (n != 3 || n != 6 || n != 12);

    std::cout << "\nVyvedete lihva v realno chislo:";
    std::cin >> p;

    for (i = 0; i < N; ++i)
    {
        if (n == 3)
        {
            A[i].M3.suma = A[i].M3.suma * p + A[i].M3.suma;
        }
        if (n == 6)
        {
            A[i].M6.suma = A[i].M6.suma * p + A[i].M6.suma;
        }
        if (n == 12)
        {
            A[i].M12.suma = A[i].M12.suma * p + A[i].M12.suma;
        }
    }
}


void spravka ()
{
    int i;
    char n[15];
    std::cout << "\nVyvedi ime:";
    std::cin >> n;
    for (i = 0; i < N; ++i)
    {
        if (A[i].ime == n) {
            disp (i);
        }
    }
}


void izvejdane ()
{
    int i, k, z;
    double temp;
    for (i = 0; i < N; ++i)
    {
        for (z = i + 1; z < N + 1; ++z)
        {
            if (A[i].smetka > A[z].smetka)
            {
                temp = A[i].smetka;
                A[i].smetka = A[z].smetka;
                A[z].smetka = temp;
            }
        }
    }
    for (i = 0; i < N; ++i) {
        disp (i);
    }
}


void load ()
{
    std::FILE * fp;
    int i;
    if ((fp = fopen ("vlojiteli12.dat", "rb")) == NULL)
    {
        std::cout << "\nEROR 404: File not found! ";
        return;
    }
    if (fread (&top, sizeof (top), 1, fp) != 1)
    {
        std::cout << "\nError size";
        exit (1);
    }
    for (i = 0; i < top; ++i)
    {
        if (fread (&A[i], sizeof (vlojiteli), 1, fp) != 1)
        {
            std::cout << "\nError reading structure!";
            exit (1);
        }
    }
}


void save ()
{
    std::FILE * fp;
    int i;
    if ((fp = fopen ("vlojiteli12.dat", "wb")) == NULL)
    {
        std::cout << "\nError saving file!";
        return;
    }
    if (fwrite (&top, sizeof (top), 1, fp) != 1)
    {
        std::cout << "\nError w top";
        exit (1);
    }
    for (i = 0; i < top; ++i)
    {
        if (fwrite (&A[i], sizeof (vlojiteli), 1, fp) != 1)
        {
            std::cout << "\nError writing str!";
            exit (1);
        }
    }
    fclose (fp);
}

Topic archived. No new replies allowed.