,   CyberForum.ru

, TEMPLATE - C++

 
 
:  :  - 10,   - 4.90
correct
   correct
-1 / 3 / 1
: 20.04.2011
: 412
03.01.2013, 20:55     , TEMPLATE #1
, .
:
" ". , :
- ,
- ,
- ,
- .
:
- ,
- ,
- ,
- ,
- .
-----------------------------------------------
, - ?
. :
 , TEMPLATE
, , , , ?

---------------------------------------------------------
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
//---------------------------------------------------------------------------
 #include <iostream.h>
#include <vcl.h>
#pragma hdrstop
 
//---------------------------------------------------------------------------
 
#pragma argsused
int main(int argc, char* argv[])
{      // ===================  TEMPLATE.AVB ======================
#define FILENAME "BZavia.txt"
#define TEMPFILE "Temp"
#define MAX 20
// -  
template <class T>              //   aviabilets
class aviabilets {
private:
FILE *fp, *tp, *printer;
 int slots[MAX];
 int count;
 
public:
  nofind();      //  -  
  openrw();      //     
  openwr();      //    
  getslots();    //   -   
  getslot();     //    
  adbilet();     //  
  delbilet();    //     
  showbilet();   //    
  chbilet();     //   
  chcell();      //   
  sortcells();   //    
  loc_punkt();   //     
  loc_fio();     //   
  loc_datvl();   //    
  pbilets();     //  
 
 };
 struct BZ                  //    
 {
  // private:
  char punktn[20];         //  
  char nreis[10];          //  
  char fio[50];            //    
  char datvl[10];          //  
  int number;              //       
      } disc;              // .
 
// **********************************************
   template<class T>
   aviabilets<T>::nofind() //  -  
        {
         char pause;
         puts("\n      ");
         getche();
        // pause=getchar();
         return 0;
        }
// **********************************************
     template<class T>
     aviabilets<T>::openrw() //     
       {
        if((fp = fopen(FILENAME,"r")) == NULL)
         {
          printf("   %s\n", FILENAME);
          exit(0);
         }
       if((tp = fopen(TEMPFILE,"w")) == NULL)
        {
          printf("   %s\n", TEMPFILE);
          fclose(fp);
          exit(0);
        }
        return 0;
        }
 
 
// **********************************************
                                 template<class T>
//      c aviabilets<T>::
 
// **********************************************
// ===========================================================
 
  (TEMPLATE.AVB)      
    *.h
  :
#include "stdio.h"
# include <conio.h>
# include <stdlib.h>
# include <string.h>
# include <iostream.h>
 
 
 
   - ABILET.CPP
   
 
// ========================= ABILET.CPP ======================
/*  */
#include  <template.avb> //     aviabilets
#include  <stdio.h>
# include <conio.h>
# include <stdlib.h>
# include <string.h>
# include <iostream.h>
 
// ++++++++++++++++++++   ++++++++++++++++++++++
 main()
      {
       aviabilets<char> a; //    a
       char select;
       a.getslots();
    do
      {
      clrscr();
       puts("     \n");
       puts("1     \n");
       puts("2    \n");
       puts("3   \n");
       puts("4   \n");
       puts("5   \n");
       puts("6  \n");
       puts("7   \n");
       puts("8   \n");
       printf(",   : ");
     select = getchar();
     putchar('\n');
     switch(select)
    {
      case '1':
      a.adbilet();
        break;
      case '2':
      a.delbilet();
        break;
      case '3':
      a.chbilet();
        break;
      case '4':
      a.chcell();
        break;
      case '5':
      a.sortcells();
        break;
      case '6':
      a.loc_punkt();
        break;
      case '7':
      a.pbilets();
        break;
      case '8':
        break;
      default:
      puts(",  \n\n");
    }
       }
     while(select!='8');
     return 0;
     }
 
}
//---------------------------------------------------------------------------
----------------------------
,!
.
Buildog
40 / 40 / 2
: 29.04.2012
: 185
03.01.2013, 21:31     , TEMPLATE #2
.h , , main.cpp
correct
   correct
-1 / 3 / 1
: 20.04.2011
: 412
03.01.2013, 21:35  []     , TEMPLATE #3
Buildog
.h , , main.cpp
, ?
Buildog
40 / 40 / 2
: 29.04.2012
: 185
03.01.2013, 21:36     , TEMPLATE #4
int main(int argc, char* argv[]) ? .AVB ( ). ,

C++
1
//      c aviabilets<T>::
Avazart
   Avazart
6897 / 5137 / 252
: 10.12.2010
: 22,570
: 17
03.01.2013, 21:36     , TEMPLATE #5
- , main(),
Buildog
40 / 40 / 2
: 29.04.2012
: 185
03.01.2013, 21:38     , TEMPLATE #6
.h
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
#pragma once
#include <iostream> //  ,  
 
template <class T>              //   aviabilets
class aviabilets {
private:
FILE *fp, *tp, *printer;
 int slots[MAX];
 int count;
 
public:
  nofind();      //  -  
  openrw();      //     
  openwr();      //    
  getslots();    //   -   
  getslot();     //    
  adbilet();     //  
  delbilet();    //     
  showbilet();   //    
  chbilet();     //   
  chcell();      //   
  sortcells();   //    
  loc_punkt();   //     
  loc_fio();     //   
  loc_datvl();   //    
  pbilets();     //  
 
 };
 struct BZ                  //    
 {
  // private:
  char punktn[20];         //  
  char nreis[10];          //  
  char fio[50];            //    
  char datvl[10];          //  
  int number;              //       
      } disc;              // .
 
// **********************************************
   template<class T>
   aviabilets<T>::nofind() //  -  
        {
         char pause;
         puts("\n      ");
         getche();
        // pause=getchar();
         return 0;
        }
// **********************************************
     template<class T>
     aviabilets<T>::openrw() //     
       {
        if((fp = fopen(FILENAME,"r")) == NULL)
         {
          printf("   %s\n", FILENAME);
          exit(0);
         }
       if((tp = fopen(TEMPFILE,"w")) == NULL)
        {
          printf("   %s\n", TEMPFILE);
          fclose(fp);
          exit(0);
        }
        return 0;
        }
correct
   correct
-1 / 3 / 1
: 20.04.2011
: 412
03.01.2013, 21:41  []     , TEMPLATE #7
, ?
Buildog
40 / 40 / 2
: 29.04.2012
: 185
03.01.2013, 21:43     , TEMPLATE #8
?
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
openwr();      //    
  getslots();    //   -   
  getslot();     //    
  adbilet();     //  
  delbilet();    //     
  showbilet();   //    
  chbilet();     //   
  chcell();      //   
  sortcells();   //    
  loc_punkt();   //     
  loc_fio();     //   
  loc_datvl();   //    
  pbilets();     //  
2

C++
1
2
  nofind();      //  -  
  openrw();      //     
correct
   correct
-1 / 3 / 1
: 20.04.2011
: 412
03.01.2013, 21:47  []     , TEMPLATE #9
... ?
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
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
#   include <string.h>
#   include <iostream.h>
#   include <windows.h>
class Avia
{
public:
char punkt[15], fio[50]; int namber, data[3]; Avia *Next; Avia();
Avia(char* al, char* bl, int, int*);
};
class List {
public:
Avia* First;
ListO;
void Add(Avia *pNext); //    Avia* Poisk();
void ShowAll(); //  
Avia* FindAvia(int nomer, int *datal); //   Avia* GetPrev(Avia *p); int GetCount();
Avia * GetAt(int n); //      bool RemoveAvia(int nomer, int *datal); // 
};
Avia::Avia()
{
memset(punkt,0,sizeof(punkt)); 
memset(fio,0,sizeof(fio));
Next=NULL; //   
Avia::Avia(char* al, char* bl, int namberl, int *datal)
{
strcpy(punkt, al); strcpy(fio, b 1); namber=namberl;
for (int i=0; i<3; i++) data[i]=datal[i];
Next=NULL; //   
}
List::List()
{
First=NULL; //   
}
void List::Add(Avia *pNext)
{
//    . if(First!=NULL)
Poisk()->Next = pNext;
else
//   , First = pNext;
}
Avia* List: :Poisk()
{
Avia *X = First;
//    if(X == NULL) return NULL;
//     . whi!e(X->Next!=NULL) X = X->Next;
return X;
}
void List::ShowAll()
{
//      . Avia * pCurr = First; //   
if(pCurr == NULL)
{
<" ";
}
//     , do
//     . coutpCurr->fio"\t"pCurr->punkt"\t"pCurr->namber"\t"pCurr- >data[0]"."pCurr->data[l]"."pCurr->data[2]"\n"; 
while((pCurr = pCurr->Next)!=NULL);
Avia* List::FindAvia(int nomer, int *datal)
{
int flag=0;
//      . Avia * pCurr = First;
//   ,   NULL.
if(pCurr == NULL) {
٫" ";
}
//    . do{
//    ,    .
if(pCurr->namber==nomer && pCurr->data[0]==datal [0] && pCurr->data[l]==datal[l] &&
pCurr->data[2]==data 1 [2]) {
//   
coiit<<pCurr->fio<<''\t',<<pCurr->punkt<<''\t''<<pCurr->namber<<''\t''<<pCurr- >data[0]". "<<pCurr->data[ 1 ]". "<<pCurr->data[2] <<"\n"; flag=l; return pCurr;
}
}while((pCurr = pCurr->Next)!=NULL);
if (flag==0) ٫"  HeT"endl; return pCurr;
}
Avia* List::GetPrev(Avia *p)
{
//      (. .     ),  
NULL.
if(p == First)
return NULL; //    . Avia * pCurr = First; do{
if(pCurr->Next==p) { //   , return pCurr;
}
//  pCurr     . }while((pCurr = pCurr->Next)!=NULL); return NULL;
}
int List::GetCount()
{
//      . Avia * pCurr = First; //   
if(pCurr == NULL)
{
return 0;
int count = 1; //   . //     .
while(pCurr->Next!=NULL)
{
//   . pCurr = pCurr->Next; //  . count++;
}
return count;
Avia * List::GetAt(int n)
{
//      . Avia * pCurr = First;
//         ,  NULL.
if(pCurr == NULL || n>GetCount()-l)
{
return NULL;
}
//      .
for(int i=0; i<GetCount(); i++) {
if(i==n) {
return pCurr;
}
pCurr = pCurr->Next;
}
return NULL;
bool List::RemoveAvia(int nomer, int *datal)
{
//    if(First == NULL)
{ ث" "; return false;}
//    . Avia* pData = FindAvia(nomer, datal); //       if(pData == NULL)
{ cout"TaKoro  "; return false;
}
//    -   .
if(pData == First)
{
First = pData->Next; delete pData; return true;
}
//    -    . GetPrev(pData)->Next = pData->Next; 
delete pData;
<" "; return true;
main() {
List list; Avia *pData; char p[15], fio[15];
int n, namber, data[3]; bool flag=false; SetConsoleOutputCP( 1251);
while (1)
{
cout"l  3anBKy"endl; cout"2   3aHBKn"endl; cout"3  3aHBKH"endl; cout"4  3aflBKy"endl; cout"5 Bbixofl"endl; cout"n="; cinn;
switch (n) {
case 1:
{
<"  "1^1; cinp;
cout"    nacca>icnpa"endl; cinfio;
cout"    pefica"endl; cinnamber;
<"  "1; <": "; cindata[0]; <": "; cindata[l]; coutTcw "; cindata[2]; coutendl;
pData = new Avia(p, fio, namber, data);
list.Add(pData);
break;
}
case 2:
{
list.ShowAll(); break;
}
case 3:
{
1"  peiica"endl; cinnamber;
1"  BbuieTa"endl; <": "; cindata[0]; cout"MecHu: "; cindata[l]; <": "; cindata[2];
cout"\n";
list.FindAvia(namber, data); break;
case 4:
{
1"  pefica"endl; cinnamber;
1"  BbmeTa"endl; cout"4Hono: "; cindata[0]; cout"MecHu: "; cindata[l]; <": "; cindata[2]; cout"\n";
list.RemoveAvia(namber, data); break;
case 5:
return 0;
default:
cout"TaKoro   .  "1;
} }
return 0; 
16 ( 3.2)
  ,       -    ,  , , ,     .
 :   (=),    .
 ,     .    ,      .

#include <iostream.h> #include <windows.h> #include <math.h> #include <conio.h>
class Set {
public:
Set();
int count;  //   
int element[ 100]; // 
void set(); //  
void get(); // 
void addElement(); //   
void delElement(); //   
Set operator+(Set); //
Set operator-(Set); //
Set operator*(Set); //
Set& operator=(Set);//nepenpHCBaHBaHne
bool operator==(Set);//cpaBHeHne  
bool operator<(Set);//cpaBHeiiHe  
};
Set::Set() {
count=0;
\
i
void Set::set() {
<"   : "; cincount;
for(int j=0; j<count;j++) {
cout"    : "; cinelement[j];
}
void Set::get()
{
for (int i=0; i<count; i++) coutelement[i]" "; coutendl; 
void Set::addElement()
{
<"  : ";
cinelement[count];
count++;
void Set::delElement() {
int n;
<"     : "; cinn;
for(int i=n; i<count-l; i++) element[i]=element[i+l]; count;
Set Set::operator+(Set el)
{
Set tmp;
int ij, flag, n;
tmp.count=0;
for(i=0; i<count; i++) tmp.element[i]=element[i]; n=count;
for(i=0; i<el.count;i++)
{
flag = 0;
for(j=0; j<el.count;j++)
if (el.element[i]==tmp.element[j]) flag=l; if (flag==0) {tmp.element[n]=el.element[i]; n++;}
\
tmp.count=n; return tmp;
Set Set::operator*(Set el) {
Set tmp; int i,j, flag, n; tmp.count=0; n=0;
for(i=0; i<count;i++) {
flag = 0;
for(j=0; j<el.count;j++)
if (element[i]==el.element[j]) flag=l; if(flag==l) {tmp.element[n]=element[i]; n++;}
}
tmp.count=n; return tmp;
Set Set::operator-(Set el)
Set tmp;
int ij, flag, n;
n=0;
for(i=0; i<count;i++) {
flag = 0;
for(j=0; j<el.count;j++)
if (element[i]==el.element[j]) flag=l; if(flag==0) {tmp.element[n]=element[i]; n++;}
}
tmp.count=n;
return tmp;
}
Set& Set::operator=(Set el)
{
count=el. count;
for(int i=0; i<count;i++) element[i]=el.element[i]; return *this;
bool Set::operator==(Set el)
{
int flag;
if (el.count!=count) return false;
for(int i=0; i<count;i++)
{
flag = 0;
for(int j=0; j<el.count;j++)
if (element[i]==el.element!]]) flag=l; if (flag==0) return false;
}
return true;
bool Set::operator<(Set el)
{
if (count<=el.count) return true;
else
return false;
int main()
{
int menu; Set setl, set2;
SetConsoleOutputCP( 1251);
while (1)
{
cout"\n\nMEHK)\n"; 
cout"l.  \"; cout"2.  \"; cout"3.  \"; cout"4.  \"; cout"5.  \"; cout"6.  \"; cout"7.  \"; cout"8.    \"; cout"9.    \"; cout"10. \\\";
ث"  : ";
cinmenu;
if (menu=10) exit(O);
switch(menu)
{
case 1: {setl.set(); break;}
case 2: {set 1 .addElementQ; ث"\"; setl .get(); break;} case 3: {setl,delElement(); <"\"; setl .get(); break;} case 4: {setl.set(); set2.set(); setl = setl*set2;
cout"Pe3ynbTaT\n";setl.get(); break; } case 5: {setl ,set(); set2.set(); setl = setl+set2;
ث"\";5^1(); break; } case 6: {setl .set(); set2.set(); setl = setl-set2;
cout"Pe3ynbTaT\n";setl.get(); break; } case 7: {setl .setQ; set2 = setl;
<"\";512^1(); break; } case 8: {setl.set(); set2.set();
if (setl==set2) 1" ";
else ث"  "; break; } case 9: {setl .set(); set2.set();
if (setl<set2) <"   ";
else ث"   "; break; } default:{cout"TaKoro   .   "; break;}
} }
return 0; 
13 ( 3.3)
    Integer ()          .    Decimal ()  Binary (),         .   ,    - .

#include <iostream.h> #include <windows.h> #include <string.h>
class Integer {
public:
int figure[32], count;
virtual void sum(){}; //. . 
virtual void diff(){}; //. . 
virtual void pro(){}; //. . 
virtual void input(){}; //
virtual void output(){}; //
};
//                  
class Decimal : Integer
{
public:
void input()
{
char decimal[32]; int j;
for(int i=0; i<32; i++) figure[i]=0; 1"  : "; cindecimal; count=strlen(decimal); j=count-l;
for(i=31; i>31-count; i)
{
figure[i]=decimal[j]-48;
void output()
{
for(int j=0; (j<32)&&(figure[j]==0); j++); for(int i=j; i<32; i++) coutfigure[i]; coutendl;
void sum()
{
Decimal decimal2; decimal2.input(); for (int i=31; i>0; i--) 
{
figure[i]+=decimal2.figure[i]; figurefi-1 ]+=figure[i]/l 0; figure[i] %=10;
}
1ȫ""; output();
void diff()
!
Decimal decimal2; decimal2.input();
for (int i=31; i>0; i-) {
if (figure[i]>=decimal2.figure[i]) figure[i]-=decimal2.figure[i];
else
{
figure[i]=figure[i]-decimal2.figure[i]+10;
figure[i-l]-=l;
}
}
cout" ";
output(); }
void pro()
{
Decimal d2; d2.input();
int i, j, S, P; //S -      -  Decimal W; //
if (count>d2.count) W.count=count; else W.count=d2.count; for(i=0; i<32; i++) W.figure[i]=0;
for (i=0; i<32; i++) //    d2
{
P=0; //   
for (j = 0; j<32; j++) //   d
{
S = figure[i]* d2.figure[j]+W.figure[i+j]+P;
W.figure[i+j] = S%10; //      = S/10; //  
}
W.figure[j+i] = ; //   
}
W.output();
//  -  
class Binary : Integer
{
public:
void inputQ
{ 
char binary[32]; int j;
for(int i=0; i<32; i++) figure[i]=0; 1"  : "; cinbinary; count=strlen(binary); j=count-l;
for(i=31; i>31 -count; i--)
{
if(binary[j]-48==0 || binary[j]-48==l)
{
figure[i]=binary[j]-48; j--;
}
else {
figure[i]=l; j-S
}
}
void output()
{
for(int j=0; (j<32)&&(figure[j]==0); j++); for(int i=j; i<32; i++) coutfigure[i]; coutendl;
void sum()
{
Binary b2; b2.input();
for (int i=31; i>0; i-) {
figure[i]+=b2.figure[i]; figure[i-1 ]+=figure[i]/2; figurefi] %=2;
}
<"";
output(); }
void diff() {
Binary b2; b2.input();
for (int i=31; i>0; i~) {
if (figure[i]>=b2.figure[i]) figure[i]-=b2.figure[i];
else {
figure[i]=figure[i]-b2.figure[i]+2;
figure[i-l]-=l;
}
}
cout"  "; 
output();
}
void pro()
{
Decimal d2; d2.input();
int i, j, S, P; //S -      -  Decimal W; //
if (count>d2.count) W.count=count; else W.count=d2.count; for(i=0; i<32; i++) W.figure[i]=0;
for (i=0; i<32; i++) //    d2
{
P=0; //   
for (j = 0; j<32; j++) //   d {
S = figure[i]* d2.figure[j]+W.figure[i+j]+P;
W.figure[i+j] = S%10; //    
 = S/10; //  
}
W.figure[j+i] = ; //   
}
W.output();
}
// -  -      
main()
f
int menu; Decimal dl; Binary bl;
SetConsoleOutputCP( 1251);
while (1)
{
<"\     \"; cout"l. \"; cout"2. \"; cout"3. \";
1"\     \"; cout"4. \"; cout"5. \"; cout"6. \";
cout"\n7. \";
ث" : ";
cinmenu;
if (menu==7) exit(0);
switch(menu) {
case 1: {dl.inputQ; dl.sumQ; break;}
case 2: {dl.inputQ; dl.diff(); break;}
case3: {dl.input(); dl.pro(); break:}
case4: {bl.input(); bl.sumQ; break;}
case 5: {bl.input(); bl.diffQ; break;}
case 6: {bl.input(); bl.pro(); break;}
default:{cout"TaKoro   \"; break;}
} }
return 0; return 0; 
J^II ^ j.-tj
       ,    ,     .  ,   ,         double,    .

#include <iostream.h> #include <windows.h> #include <math.h>
template <elass Type> class Complex
{
public:
Type Real, Image;
void add(Complex); //  void sub(Complex); //  void mul(Complex); //  void del(Complex); //  void Output();
void Input();
};
//    Complex
template <class Type> void Complex<Type>::add(Complex C2)
{
Real = Real + C2.Real; Image = Image + C2.Image ; Output();
}
template <class Type> void Complex<Type>:: sub(Complex C2) {
Real=Real -C2.Real; Image=Image -C2.Image ; Output();
template <class Type> void Complex<Type>:: mul(Complex C2)
{
Real=Real *C2.Real -Image *C2.Image; Image=Real*C2.Image+Image *C2.Real; OutputQ;
template <class Type> void Complex<Type>::del(Complex C2) {
Real=(Real *C2.Real+Image *C2.Image)/(pow(C2.Real,2)+pow(C2.Image,2)); Image=(-l)*(Real *C2.Image +Image *C2.Real)/(pow(C2.Real,2)+pow(C2.Image,2)); OutputQ;
template <class Type> void Complex<Type>::Input()
{
ث"   : "; cinReal;
ث"   : "; cinImage;
}
template <class > void Complex<Type>::Output() {
cout": "Real"+x*"Imageendl; }
// 
main() {
int menu;
Complex<int> cintl, cint2; Complex<float> cfloatl, cfloat2; SetConsoleOutputCP( 1251);
while (1)
{
<"\    \";
cout"l. \";
cout"2. \";
cout"3. \";
cout"4. \";
<"\    \";
cout"5. \";
cout"6. \";
cout"7. \";
cout"8. \";
cout"\n9. \";
<" : ";
cinmenu;
if (menu==9) exit(O);
switch(menu) {
case 1: {cintl.Input(); cint2.Input(); cintl.add(cint2); break;} case 2: {cintl.Input(); cint2.Input(); cintl.sub(cint2); break;} case 3: {cintl.InputQ; cint2.Input(); cintl,mul(cint2); break;} case 4: {cintl.Input(); cint2.Input(); cintl.del(cint2); break; } case 5: {cfloatl .Input(); cfloat2.Input(); cfloatl ,add(cfloat2); break;} case 6: {cfloatl .Input(); cfloat2.Input(); cfloatl .sub(cfloat2); break;} case 7: {cfloatl .Input(); cfloat2.Input(); cfloatl ,mul(cfloat2); break;} case 8: {cfloatl .Input(); cfloat2.Input(); cfloatl ,del(cfloat2); break;} default: {٫"   \"; break;}
} }
return 0; return 0; x
Buildog
40 / 40 / 2
: 29.04.2012
: 185
03.01.2013, 21:52     , TEMPLATE #10
, , 2 . . , int, double .
correct
   correct
-1 / 3 / 1
: 20.04.2011
: 412
03.01.2013, 21:59  []     , TEMPLATE #11
Buildog
, , 2 . . , int, double .
, , 2 .
.....?
Nixy
ComfyMobile
   Nixy
399 / 280 / 8
: 24.07.2012
: 916
03.01.2013, 22:01     , TEMPLATE #12
correct,

:

,

correct
   correct
-1 / 3 / 1
: 20.04.2011
: 412
03.01.2013, 22:03  []     , TEMPLATE #13
Nixy
correct,

:

,

, .
Buildog
40 / 40 / 2
: 29.04.2012
: 185
03.01.2013, 22:04     , TEMPLATE #14
. . . , .
correct
   correct
-1 / 3 / 1
: 20.04.2011
: 412
03.01.2013, 22:08  []     , TEMPLATE #15
Buildog
.h
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
#pragma once
#include <iostream> //  ,  
 
template <class T>              //   aviabilets
class aviabilets {
private:
FILE *fp, *tp, *printer;
 int slots[MAX];
 int count;
 
public:
  nofind();      //  -  
  openrw();      //     
  openwr();      //    
  getslots();    //   -   
  getslot();     //    
  adbilet();     //  
  delbilet();    //     
  showbilet();   //    
  chbilet();     //   
  chcell();      //   
  sortcells();   //    
  loc_punkt();   //     
  loc_fio();     //   
  loc_datvl();   //    
  pbilets();     //  
 
 };
 struct BZ                  //    
 {
  // private:
  char punktn[20];         //  
  char nreis[10];          //  
  char fio[50];            //    
  char datvl[10];          //  
  int number;              //       
      } disc;              // .
 
// **********************************************
   template<class T>
   aviabilets<T>::nofind() //  -  
        {
         char pause;
         puts("\n      ");
         getche();
        // pause=getchar();
         return 0;
        }
// **********************************************
     template<class T>
     aviabilets<T>::openrw() //     
       {
        if((fp = fopen(FILENAME,"r")) == NULL)
         {
          printf("   %s\n", FILENAME);
          exit(0);
         }
       if((tp = fopen(TEMPFILE,"w")) == NULL)
        {
          printf("   %s\n", TEMPFILE);
          fclose(fp);
          exit(0);
        }
        return 0;
        }
? , ...?
Buildog
40 / 40 / 2
: 29.04.2012
: 185
03.01.2013, 22:20     , TEMPLATE #16
, , .

40
, ..

9
... , ...
correct
   correct
-1 / 3 / 1
: 20.04.2011
: 412
03.01.2013, 22:29  []     , TEMPLATE #17
. , ... ?
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
1
2
3
4
5
6
7
8
9
10
11
12
13
openwr();      //    
  getslots();    //   -   
  getslot();     //    
  adbilet();     //  
  delbilet();    //     
  showbilet();   //    
  chbilet();     //   
  chcell();      //   
  sortcells();   //    
  loc_punkt();   //     
  loc_fio();     //   
  loc_datvl();   //    
  pbilets();     //  
1
? ..


correct
... ?
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
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
#   include <string.h>
#   include <iostream.h>
#   include <windows.h>
class Avia
{
public:
char punkt[15], fio[50]; int namber, data[3]; Avia *Next; Avia();
Avia(char* al, char* bl, int, int*);
};
class List {
public:
Avia* First;
ListO;
void Add(Avia *pNext); //    Avia* Poisk();
void ShowAll(); //  
Avia* FindAvia(int nomer, int *datal); //   Avia* GetPrev(Avia *p); int GetCount();
Avia * GetAt(int n); //      bool RemoveAvia(int nomer, int *datal); // 
};
Avia::Avia()
{
memset(punkt,0,sizeof(punkt)); 
memset(fio,0,sizeof(fio));
Next=NULL; //   
Avia::Avia(char* al, char* bl, int namberl, int *datal)
{
strcpy(punkt, al); strcpy(fio, b 1); namber=namberl;
for (int i=0; i<3; i++) data[i]=datal[i];
Next=NULL; //   
}
List::List()
{
First=NULL; //   
}
void List::Add(Avia *pNext)
{
//    . if(First!=NULL)
Poisk()->Next = pNext;
else
//   , First = pNext;
}
Avia* List: :Poisk()
{
Avia *X = First;
//    if(X == NULL) return NULL;
//     . whi!e(X->Next!=NULL) X = X->Next;
return X;
}
void List::ShowAll()
{
//      . Avia * pCurr = First; //   
if(pCurr == NULL)
{
<" ";
}
//     , do
//     . coutpCurr->fio"\t"pCurr->punkt"\t"pCurr->namber"\t"pCurr- >data[0]"."pCurr->data[l]"."pCurr->data[2]"\n"; 
while((pCurr = pCurr->Next)!=NULL);
Avia* List::FindAvia(int nomer, int *datal)
{
int flag=0;
//      . Avia * pCurr = First;
//   ,   NULL.
if(pCurr == NULL) {
٫" ";
}
//    . do{
//    ,    .
if(pCurr->namber==nomer && pCurr->data[0]==datal [0] && pCurr->data[l]==datal[l] &&
pCurr->data[2]==data 1 [2]) {
//   
coiit<<pCurr->fio<<''\t',<<pCurr->punkt<<''\t''<<pCurr->namber<<''\t''<<pCurr- >data[0]". "<<pCurr->data[ 1 ]". "<<pCurr->data[2] <<"\n"; flag=l; return pCurr;
}
}while((pCurr = pCurr->Next)!=NULL);
if (flag==0) ٫"  HeT"endl; return pCurr;
}
Avia* List::GetPrev(Avia *p)
{
//      (. .     ),  
NULL.
if(p == First)
return NULL; //    . Avia * pCurr = First; do{
if(pCurr->Next==p) { //   , return pCurr;
}
//  pCurr     . }while((pCurr = pCurr->Next)!=NULL); return NULL;
}
int List::GetCount()
{
//      . Avia * pCurr = First; //   
if(pCurr == NULL)
{
return 0;
int count = 1; //   . //     .
while(pCurr->Next!=NULL)
{
//   . pCurr = pCurr->Next; //  . count++;
}
return count;
Avia * List::GetAt(int n)
{
//      . Avia * pCurr = First;
//         ,  NULL.
if(pCurr == NULL || n>GetCount()-l)
{
return NULL;
}
//      .
for(int i=0; i<GetCount(); i++) {
if(i==n) {
return pCurr;
}
pCurr = pCurr->Next;
}
return NULL;
bool List::RemoveAvia(int nomer, int *datal)
{
//    if(First == NULL)
{ ث" "; return false;}
//    . Avia* pData = FindAvia(nomer, datal); //       if(pData == NULL)
{ cout"TaKoro  "; return false;
}
//    -   .
if(pData == First)
{
First = pData->Next; delete pData; return true;
}
//    -    . GetPrev(pData)->Next = pData->Next; 
delete pData;
<" "; return true;
main() {
List list; Avia *pData; char p[15], fio[15];
int n, namber, data[3]; bool flag=false; SetConsoleOutputCP( 1251);
while (1)
{
cout"l  3anBKy"endl; cout"2   3aHBKn"endl; cout"3  3aHBKH"endl; cout"4  3aflBKy"endl; cout"5 Bbixofl"endl; cout"n="; cinn;
switch (n) {
case 1:
{
<"  "1^1; cinp;
cout"    nacca>icnpa"endl; cinfio;
cout"    pefica"endl; cinnamber;
<"  "1; <": "; cindata[0]; <": "; cindata[l]; coutTcw "; cindata[2]; coutendl;
pData = new Avia(p, fio, namber, data);
list.Add(pData);
break;
}
case 2:
{
list.ShowAll(); break;
}
case 3:
{
1"  peiica"endl; cinnamber;
1"  BbuieTa"endl; <": "; cindata[0]; cout"MecHu: "; cindata[l]; <": "; cindata[2];
cout"\n";
list.FindAvia(namber, data); break;
case 4:
{
1"  pefica"endl; cinnamber;
1"  BbmeTa"endl; cout"4Hono: "; cindata[0]; cout"MecHu: "; cindata[l]; <": "; cindata[2]; cout"\n";
list.RemoveAvia(namber, data); break;
case 5:
return 0;
default:
cout"TaKoro   .  "1;
} }
return 0; 
16 ( 3.2)
  ,       -    ,  , , ,     .
 :   (=),    .
 ,     .    ,      .

#include <iostream.h> #include <windows.h> #include <math.h> #include <conio.h>
class Set {
public:
Set();
int count;  //   
int element[ 100]; // 
void set(); //  
void get(); // 
void addElement(); //   
void delElement(); //   
Set operator+(Set); //
Set operator-(Set); //
Set operator*(Set); //
Set& operator=(Set);//nepenpHCBaHBaHne
bool operator==(Set);//cpaBHeHne  
bool operator<(Set);//cpaBHeiiHe  
};
Set::Set() {
count=0;
\
i
void Set::set() {
<"   : "; cincount;
for(int j=0; j<count;j++) {
cout"    : "; cinelement[j];
}
void Set::get()
{
for (int i=0; i<count; i++) coutelement[i]" "; coutendl; 
void Set::addElement()
{
<"  : ";
cinelement[count];
count++;
void Set::delElement() {
int n;
<"     : "; cinn;
for(int i=n; i<count-l; i++) element[i]=element[i+l]; count;
Set Set::operator+(Set el)
{
Set tmp;
int ij, flag, n;
tmp.count=0;
for(i=0; i<count; i++) tmp.element[i]=element[i]; n=count;
for(i=0; i<el.count;i++)
{
flag = 0;
for(j=0; j<el.count;j++)
if (el.element[i]==tmp.element[j]) flag=l; if (flag==0) {tmp.element[n]=el.element[i]; n++;}
\
tmp.count=n; return tmp;
Set Set::operator*(Set el) {
Set tmp; int i,j, flag, n; tmp.count=0; n=0;
for(i=0; i<count;i++) {
flag = 0;
for(j=0; j<el.count;j++)
if (element[i]==el.element[j]) flag=l; if(flag==l) {tmp.element[n]=element[i]; n++;}
}
tmp.count=n; return tmp;
Set Set::operator-(Set el)
Set tmp;
int ij, flag, n;
n=0;
for(i=0; i<count;i++) {
flag = 0;
for(j=0; j<el.count;j++)
if (element[i]==el.element[j]) flag=l; if(flag==0) {tmp.element[n]=element[i]; n++;}
}
tmp.count=n;
return tmp;
}
Set& Set::operator=(Set el)
{
count=el. count;
for(int i=0; i<count;i++) element[i]=el.element[i]; return *this;
bool Set::operator==(Set el)
{
int flag;
if (el.count!=count) return false;
for(int i=0; i<count;i++)
{
flag = 0;
for(int j=0; j<el.count;j++)
if (element[i]==el.element!]]) flag=l; if (flag==0) return false;
}
return true;
bool Set::operator<(Set el)
{
if (count<=el.count) return true;
else
return false;
int main()
{
int menu; Set setl, set2;
SetConsoleOutputCP( 1251);
while (1)
{
cout"\n\nMEHK)\n"; 
cout"l.  \"; cout"2.  \"; cout"3.  \"; cout"4.  \"; cout"5.  \"; cout"6.  \"; cout"7.  \"; cout"8.    \"; cout"9.    \"; cout"10. \\\";
ث"  : ";
cinmenu;
if (menu=10) exit(O);
switch(menu)
{
case 1: {setl.set(); break;}
case 2: {set 1 .addElementQ; ث"\"; setl .get(); break;} case 3: {setl,delElement(); <"\"; setl .get(); break;} case 4: {setl.set(); set2.set(); setl = setl*set2;
cout"Pe3ynbTaT\n";setl.get(); break; } case 5: {setl ,set(); set2.set(); setl = setl+set2;
ث"\";5^1(); break; } case 6: {setl .set(); set2.set(); setl = setl-set2;
cout"Pe3ynbTaT\n";setl.get(); break; } case 7: {setl .setQ; set2 = setl;
<"\";512^1(); break; } case 8: {setl.set(); set2.set();
if (setl==set2) 1" ";
else ث"  "; break; } case 9: {setl .set(); set2.set();
if (setl<set2) <"   ";
else ث"   "; break; } default:{cout"TaKoro   .   "; break;}
} }
return 0; 
13 ( 3.3)
    Integer ()          .    Decimal ()  Binary (),         .   ,    - .

#include <iostream.h> #include <windows.h> #include <string.h>
class Integer {
public:
int figure[32], count;
virtual void sum(){}; //. . 
virtual void diff(){}; //. . 
virtual void pro(){}; //. . 
virtual void input(){}; //
virtual void output(){}; //
};
//                  
class Decimal : Integer
{
public:
void input()
{
char decimal[32]; int j;
for(int i=0; i<32; i++) figure[i]=0; 1"  : "; cindecimal; count=strlen(decimal); j=count-l;
for(i=31; i>31-count; i)
{
figure[i]=decimal[j]-48;
void output()
{
for(int j=0; (j<32)&&(figure[j]==0); j++); for(int i=j; i<32; i++) coutfigure[i]; coutendl;
void sum()
{
Decimal decimal2; decimal2.input(); for (int i=31; i>0; i--) 
{
figure[i]+=decimal2.figure[i]; figurefi-1 ]+=figure[i]/l 0; figure[i] %=10;
}
1ȫ""; output();
void diff()
!
Decimal decimal2; decimal2.input();
for (int i=31; i>0; i-) {
if (figure[i]>=decimal2.figure[i]) figure[i]-=decimal2.figure[i];
else
{
figure[i]=figure[i]-decimal2.figure[i]+10;
figure[i-l]-=l;
}
}
cout" ";
output(); }
void pro()
{
Decimal d2; d2.input();
int i, j, S, P; //S -      -  Decimal W; //
if (count>d2.count) W.count=count; else W.count=d2.count; for(i=0; i<32; i++) W.figure[i]=0;
for (i=0; i<32; i++) //    d2
{
P=0; //   
for (j = 0; j<32; j++) //   d
{
S = figure[i]* d2.figure[j]+W.figure[i+j]+P;
W.figure[i+j] = S%10; //      = S/10; //  
}
W.figure[j+i] = ; //   
}
W.output();
//  -  
class Binary : Integer
{
public:
void inputQ
{ 
char binary[32]; int j;
for(int i=0; i<32; i++) figure[i]=0; 1"  : "; cinbinary; count=strlen(binary); j=count-l;
for(i=31; i>31 -count; i--)
{
if(binary[j]-48==0 || binary[j]-48==l)
{
figure[i]=binary[j]-48; j--;
}
else {
figure[i]=l; j-S
}
}
void output()
{
for(int j=0; (j<32)&&(figure[j]==0); j++); for(int i=j; i<32; i++) coutfigure[i]; coutendl;
void sum()
{
Binary b2; b2.input();
for (int i=31; i>0; i-) {
figure[i]+=b2.figure[i]; figure[i-1 ]+=figure[i]/2; figurefi] %=2;
}
<"";
output(); }
void diff() {
Binary b2; b2.input();
for (int i=31; i>0; i~) {
if (figure[i]>=b2.figure[i]) figure[i]-=b2.figure[i];
else {
figure[i]=figure[i]-b2.figure[i]+2;
figure[i-l]-=l;
}
}
cout"  "; 
output();
}
void pro()
{
Decimal d2; d2.input();
int i, j, S, P; //S -      -  Decimal W; //
if (count>d2.count) W.count=count; else W.count=d2.count; for(i=0; i<32; i++) W.figure[i]=0;
for (i=0; i<32; i++) //    d2
{
P=0; //   
for (j = 0; j<32; j++) //   d {
S = figure[i]* d2.figure[j]+W.figure[i+j]+P;
W.figure[i+j] = S%10; //    
 = S/10; //  
}
W.figure[j+i] = ; //   
}
W.output();
}
// -  -      
main()
f
int menu; Decimal dl; Binary bl;
SetConsoleOutputCP( 1251);
while (1)
{
<"\     \"; cout"l. \"; cout"2. \"; cout"3. \";
1"\     \"; cout"4. \"; cout"5. \"; cout"6. \";
cout"\n7. \";
ث" : ";
cinmenu;
if (menu==7) exit(0);
switch(menu) {
case 1: {dl.inputQ; dl.sumQ; break;}
case 2: {dl.inputQ; dl.diff(); break;}
case3: {dl.input(); dl.pro(); break:}
case4: {bl.input(); bl.sumQ; break;}
case 5: {bl.input(); bl.diffQ; break;}
case 6: {bl.input(); bl.pro(); break;}
default:{cout"TaKoro   \"; break;}
} }
return 0; return 0; 
J^II ^ j.-tj
       ,    ,     .  ,   ,         double,    .

#include <iostream.h> #include <windows.h> #include <math.h>
template <elass Type> class Complex
{
public:
Type Real, Image;
void add(Complex); //  void sub(Complex); //  void mul(Complex); //  void del(Complex); //  void Output();
void Input();
};
//    Complex
template <class Type> void Complex<Type>::add(Complex C2)
{
Real = Real + C2.Real; Image = Image + C2.Image ; Output();
}
template <class Type> void Complex<Type>:: sub(Complex C2) {
Real=Real -C2.Real; Image=Image -C2.Image ; Output();
template <class Type> void Complex<Type>:: mul(Complex C2)
{
Real=Real *C2.Real -Image *C2.Image; Image=Real*C2.Image+Image *C2.Real; OutputQ;
template <class Type> void Complex<Type>::del(Complex C2) {
Real=(Real *C2.Real+Image *C2.Image)/(pow(C2.Real,2)+pow(C2.Image,2)); Image=(-l)*(Real *C2.Image +Image *C2.Real)/(pow(C2.Real,2)+pow(C2.Image,2)); OutputQ;
template <class Type> void Complex<Type>::Input()
{
ث"   : "; cinReal;
ث"   : "; cinImage;
}
template <class > void Complex<Type>::Output() {
cout": "Real"+x*"Imageendl; }
// 
main() {
int menu;
Complex<int> cintl, cint2; Complex<float> cfloatl, cfloat2; SetConsoleOutputCP( 1251);
while (1)
{
<"\    \";
cout"l. \";
cout"2. \";
cout"3. \";
cout"4. \";
<"\    \";
cout"5. \";
cout"6. \";
cout"7. \";
cout"8. \";
cout"\n9. \";
<" : ";
cinmenu;
if (menu==9) exit(O);
switch(menu) {
case 1: {cintl.Input(); cint2.Input(); cintl.add(cint2); break;} case 2: {cintl.Input(); cint2.Input(); cintl.sub(cint2); break;} case 3: {cintl.InputQ; cint2.Input(); cintl,mul(cint2); break;} case 4: {cintl.Input(); cint2.Input(); cintl.del(cint2); break; } case 5: {cfloatl .Input(); cfloat2.Input(); cfloatl ,add(cfloat2); break;} case 6: {cfloatl .Input(); cfloat2.Input(); cfloatl .sub(cfloat2); break;} case 7: {cfloatl .Input(); cfloat2.Input(); cfloatl ,mul(cfloat2); break;} case 8: {cfloatl .Input(); cfloat2.Input(); cfloatl ,del(cfloat2); break;} default: {٫"   \"; break;}
} }
return 0; return 0; x
Buildog
40 / 40 / 2
: 29.04.2012
: 185
03.01.2013, 22:35     , TEMPLATE #18
, , , . ( )
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
#ifndef _TEMP_H
#define _TEMP_H
#include <iostream>
 
using namespace std;
 
template <class T>
struct ListElem
{
    T item;
    ListElem *next;
};
 
template <class T>
class List
{
public:
    List();
    ~List();
    void AddElem(T item);
    void AddElem(T item, int position);
    void SearchMin();
    void SearchMax();
    void ShowList();
    void Sort();
    void Swap(T& theA, T& theB);
    void DelElem (int position);
private:
    ListElem<T> *Head;
    int SizeList;
};
 
template <class T>
List<T>::List()
{
    Head = NULL;
    SizeList = 0;
}
 
template <class T>
List<T>::~List()
{
    while(Head)
    {
        ListElem<T> *temp = Head;
        Head = Head->next;
        delete temp;
        temp = NULL; 
    }
    SizeList = 0;
}
#endif
2
400+ ... , , 73 , .
correct
   correct
-1 / 3 / 1
: 20.04.2011
: 412
04.01.2013, 23:14  []     , TEMPLATE #19
Buildog
, , , . ( )
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
#ifndef _TEMP_H
#define _TEMP_H
#include <iostream>
 
using namespace std;
 
template <class T>
struct ListElem
{
    T item;
    ListElem *next;
};
 
template <class T>
class List
{
public:
    List();
    ~List();
    void AddElem(T item);
    void AddElem(T item, int position);
    void SearchMin();
    void SearchMax();
    void ShowList();
    void Sort();
    void Swap(T& theA, T& theB);
    void DelElem (int position);
private:
    ListElem<T> *Head;
    int SizeList;
};
 
template <class T>
List<T>::List()
{
    Head = NULL;
    SizeList = 0;
}
 
template <class T>
List<T>::~List()
{
    while(Head)
    {
        ListElem<T> *temp = Head;
        Head = Head->next;
        delete temp;
        temp = NULL; 
    }
    SizeList = 0;
}
#endif
2
400+ ... , , 73 , .
.. .. )

10
, :ListO;
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
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
#   include <string.h>
#   include <iostream.h>
#   include <windows.h>
class Avia
{
public:
char punkt[15], fio[50]; int namber, data[3]; Avia *Next; Avia();
Avia(char* al, char* bl, int, int*);
};
class List {
public:
Avia* First;
[COLOR="Red"]ListO;[/COLOR]
void Add(Avia *pNext); //äîá*âëå*èå â êî*åö ñïèñê* Avia* Poisk();
void ShowAll(); //ïîê*ç âñåãî ñïèñê*
Avia* FindAvia(int nomer, int *datal); //ïîèñê â ñïèñêå Avia* GetPrev(Avia *p); int GetCount();
Avia * GetAt(int n); // ïîëó÷*åò ýëåìå*ò ïî åãî *îìåðó bool RemoveAvia(int nomer, int *datal); //óä*ëå*èå ýëåìå*ò*
};
Avia::Avia()
{
memset(punkt,0,sizeof(punkt)); 
memset(fio,0,sizeof(fio));
Next=NULL; //îá*óëÿåì óê*ç*òåëü ïîñëåä*åãî ýëåìå*ò*
Avia::Avia(char* al, char* bl, int namberl, int *datal)
{
strcpy(punkt, al); strcpy(fio, b 1); namber=namberl;
for (int i=0; i<3; i++) data[i]=datal[i];
Next=NULL; //îá*óëÿåì óê*ç*òåëü ïîñëåä*åãî ýëåìå*ò*
}
List::List()
{
First=NULL; //îá*óëÿåì óê*ç*òåëü ïåðâîãî ýëåìå*ò*
}
void List::Add(Avia *pNext)
{
// Åñëè ñïèñîê *å ïóñò. if(First!=NULL)
Poisk()->Next = pNext;
else
// Åñëè ñïèñîê ïóñò, First = pNext;
}
Avia* List: :Poisk()
{
Avia *X = First;
// Åñëè ñïèñîê ïóñò if(X == NULL) return NULL;
// Ïîê* åñòü ñëåäóþùèé ýëåìå*ò ñïèñê*. whi!e(X->Next!=NULL) X = X->Next;
return X;
}
void List::ShowAll()
{
// Óê*ç*òåëü ** î÷åðåä*ûå ä***ûå â ñïèñêå. Avia * pCurr = First; // Åñëè ñïèñîê ïóñò
if(pCurr == NULL)
{
ñîèÊ<"Ñïèñîê ïóñòËï";
}
// Ïîê* åñòü ñëåäóþùèé ýëåìå*ò ñïèñê*, do
// Âûâîäèì ** êî*ñîëü î÷åðåä*îé ýëåìå*ò. coutpCurr->fio"\t"pCurr->punkt"\t"pCurr->namber"\t"pCurr- >data[0]"."pCurr->data[l]"."pCurr->data[2]"\n"; 
while((pCurr = pCurr->Next)!=NULL);
Avia* List::FindAvia(int nomer, int *datal)
{
int flag=0;
// Óê*ç*òåëü ** î÷åðåä*ûå ä***ûå â ñïèñêå. Avia * pCurr = First;
// Åñëè ñïèñîê ïóñò, òî âîçâð*ù*åì NULL.
if(pCurr == NULL) {
ñîÙ"Ñïèñê* *åò";
}
// Îáõîäèì âñå ýëåìå*òû ñïèñê*. do{
// Åñëè **øëè èñêîìûé ýëåìå*ò, òî åãî è âîçâð*ù*åì.
if(pCurr->namber==nomer && pCurr->data[0]==datal [0] && pCurr->data[l]==datal[l] &&
pCurr->data[2]==data 1 [2]) {
// Âûâîäèì ** êî*ñîëü
coiit<<pCurr->fio<<''\t",<<pCurr->punkt<<''\t''<<pCurr->namber<<''\t''<<pCurr- >data[0]". "<<pCurr->data[ 1 ]". "<<pCurr->data[2] <<"\n"; flag=l; return pCurr;
}
}while((pCurr = pCurr->Next)!=NULL);
if (flag==0) ñîÙ"Ò*êîé ç*ÿâêè HeT"endl; return pCurr;
}
Avia* List::GetPrev(Avia *p)
{
// Åñëè ïðåäûäóùåãî ýëåìå*ò* ñïèñê* *åò (ò. å. **ø ýëåìå*ò ñîâï*ä*åò ñ ïåðâûì), òî âîçâð*ùåì
NULL.
if(p == First)
return NULL; // Åñëè ïðåäûäóùèé ýëåìå*ò åñòü. Avia * pCurr = First; do{
if(pCurr->Next==p) { // âîçâð*ù*åì î÷åðåä*îé ýëåìå*ò, return pCurr;
}
// Ïåðåâîäèì pCurr ** ñëåäóþùèé ýëåìå*ò â ñïèñêå. }while((pCurr = pCurr->Next)!=NULL); return NULL;
}
int List::GetCount()
{
// Óê*ç*òåëü ** î÷åðåä*ûå ä***ûå â ñïèñêå. Avia * pCurr = First; // Åñëè ñïèñîê ïóñò
if(pCurr == NULL)
{
return 0;
int count = 1; //×èñëî ýëåìå*òîâ â ñïèñêå. // Ïîê* åñòü ñëåäóþùèé ýëåìå*ò ñïèñê*.
while(pCurr->Next!=NULL)
{
// Ïåðåõîäèì ** ñëåäóþþùåãî. pCurr = pCurr->Next; // Óâåëè÷èâ*åì ñ÷åò÷èê. count++;
}
return count;
Avia * List::GetAt(int n)
{
// Óê*ç*òåëü ** î÷åðåä*ûå ä***ûå â ñïèñêå. Avia * pCurr = First;
// Åñëè ñïèñîê ïóñò èëè ýëåìå*ò* ñ ò*êèì *îìåðîì *åò,òî âîçâð*ù*åì NULL.
if(pCurr == NULL || n>GetCount()-l)
{
return NULL;
}
// Äîáèð*åìñÿ äî ýëåìå*ò* ñ *óæ*ûì *îìåðîì.
for(int i=0; i<GetCount(); i++) {
if(i==n) {
return pCurr;
}
pCurr = pCurr->Next;
}
return NULL;
bool List::RemoveAvia(int nomer, int *datal)
{
// Åñëè ñïèñîê ïóñò if(First == NULL)
{ ñîØ"Ñïèñê* *åò"; return false;}
// Ïîëó÷*åì ýëåìå*ò äëÿ óä*ëå*èÿ. Avia* pData = FindAvia(nomer, datal); // Åñëè ò*êîãî ýëåìå*ò* â ñïèñêå *åò if(pData == NULL)
{ cout"TaKoro ýëåìå*ò* *åò"; return false;
}
// Åñëè óä*ëÿåìûé ýëåìå*ò - ïåðâûé â ñïèñêå.
if(pData == First)
{
First = pData->Next; delete pData; return true;
}
// Åñëè óä*ëÿåìûé ýëåìå*ò - *å ïåðâûé â ñïèñêå. GetPrev(pData)->Next = pData->Next; 
delete pData;
ñîèÊ<"Ýëåìå*ò óä*ëå*"; return true;
main() {
List list; Avia *pData; char p[15], fio[15];
int n, namber, data[3]; bool flag=false; SetConsoleOutputCP( 1251);
while (1)
{
cout"l Äîá*âèòü 3anBKy"endl; cout"2 Ïîê*ç*òü âñå 3aHBKn"endl; cout"3 Ïîèñê 3aHBKH"endl; cout"4 Óä*ëèòü 3aflBKy"endl; cout"5 Bbixofl"endl; cout"n="; cinn;
switch (n) {
case 1:
{
ñîèÊ<"Ââåäèòå ïó*êò **ç**÷å*èÿ"å1^1; cinp;
cout" Â âåäèòå ÔÈÎ nacca>icnpa"endl; cinfio;
cout" Â âåäèòå *îìåð pefica"endl; cinnamber;
ñîèÊ<"Ââåäèòå ä*òó âûëåò*"åï¸1; ñîèÊ<"×èñëî: "; cindata[0]; ñîèÊ<"Ìåñÿö: "; cindata[l]; coutTcw "; cindata[2]; coutendl;
pData = new Avia(p, fio, namber, data);
list.Add(pData);
break;
}
case 2:
{
list.ShowAll(); break;
}
case 3:
{
ñîè1"Ââåäèòå *îìåð peiica"endl; cinnamber;
ñîè1"Ââåäèòå ä*òó BbuieTa"endl; ñîèÊ<"×èñëî: "; cindata[0]; cout"MecHu: "; cindata[l]; ñîèÊ<"Ãîä: "; cindata[2];
cout"\n";
list.FindAvia(namber, data); break;
case 4:
{
ñîè1"Ââåäèòå *îìåð pefica"endl; cinnamber;
ñîè1"Ââåäèòå ä*òó BbmeTa"endl; cout"4Hono: "; cindata[0]; cout"MecHu: "; cindata[l]; ñîèÊ<"Ãîä: "; cindata[2]; cout"\n";
list.RemoveAvia(namber, data); break;
case 5:
return 0;
default:
cout"TaKoro ïó*êò* ìå*þ *åò. Ïîâòîðèòå ââîä"åï¸1;
} }
return 0; 
¹16 (ïîäð*çäåë 3.2)
Îïèñ*òü êë*ññ ì*îæåñòâî, ïîçâîëÿþùèé âûïîë*ÿòü îñ*îâ*ûå îïåð*öèè **ä ì*îæåñòâ*ìè - äîá*âëå*èå è óä*ëå*èå ýëåìå*ò*, îïðåäåëå*èå ÷ëå*ñòâ*, ïåðåñå÷å*èå, îáúåäè*å*èå, ð*ç*îñòü è ñèììåòðè÷**ÿ ð*ç*îñòü ì*îæåñòâ.
Ïåðåãðóçèòü îïåð*öèè: ïðèñâ*èâ**èÿ ì*îæåñòâ (=), ð*âå*ñòâ* è *åð*âå*ñòâ* ì*îæåñòâ.
Í*ïèñ*òü ïðîãð*ììó, äåìî*ñòðèðóþùóþ ð*áîòó ñ ýòèì êë*ññîì. Ïðîãð*ìì* äîëæ** ñîäåðæ*òü ìå*þ, ïîçâîëÿþùåå îñóùåñòâèòü ïðîâåðêó âñåõ ìåòîäîâ êë*ññ*.
Ðåøå*èå
#include <iostream.h> #include <windows.h> #include <math.h> #include <conio.h>
class Set {
public:
Set();
int count;  //êîëè÷åñòâî ýëåìå*òîâ â ì*îæåñòâå
int element[ 100]; //ì*îæåñòâî ýëåìå*òîâ
void set(); //ç*ä**èå ýëåìå*ò* ì*îæåñòâ*
void get(); //âûâîä ì*îæåñòâ*
void addElement(); //äîá*âèòü ýëåìå*ò â ì*îæåñòâî
void delElement(); //óä*ëèòü ýëåìå*ò èç ì*îæåñòâ*
Set operator+(Set); //îáúåäè*å*èå
Set operator-(Set); //ð*ç*îñòü
Set operator*(Set); //ïåðåñå÷å*èå
Set& operator=(Set);//nepenpHCBaHBaHne
bool operator==(Set);//cpaBHeHne ** ð*âå*ñòâî
bool operator<(Set);//cpaBHeiiHe ** *åð*âå*ñòâî
};
Set::Set() {
count=0;
\
i
void Set::set() {
ñîèÊ<"Ââåäèòå êîëè÷åñòâî ýëåìå*òîâ ì*îæåñòâ*: "; cincount;
for(int j=0; j<count;j++) {
cout" Â âåäèòå ýëåìå*ò ì*îæåñòâ*: "; cinelement[j];
}
void Set::get()
{
for (int i=0; i<count; i++) coutelement[i]" "; coutendl; 
void Set::addElement()
{
ñîèÊ<"Ââåäèòå ýëåìå*ò ì*îæåñòâ*: ";
cinelement[count];
count++;
void Set::delElement() {
int n;
ñîèÊ<"Ââåäèòå *îìåð ýëåìå*ò* ì*îæåñòâ* äëÿ óä*ëå*èÿ: "; cinn;
for(int i=n; i<count-l; i++) element[i]=element[i+l]; count;
Set Set::operator+(Set el)
{
Set tmp;
int ij, flag, n;
tmp.count=0;
for(i=0; i<count; i++) tmp.element[i]=element[i]; n=count;
for(i=0; i<el.count;i++)
{
flag = 0;
for(j=0; j<el.count;j++)
if (el.element[i]==tmp.element[j]) flag=l; if (flag==0) {tmp.element[n]=el.element[i]; n++;}
\
tmp.count=n; return tmp;
Set Set::operator*(Set el) {
Set tmp; int i,j, flag, n; tmp.count=0; n=0;
for(i=0; i<count;i++) {
flag = 0;
for(j=0; j<el.count;j++)
if (element[i]==el.element[j]) flag=l; if(flag==l) {tmp.element[n]=element[i]; n++;}
}
tmp.count=n; return tmp;
Set Set::operator-(Set el)
Set tmp;
int ij, flag, n;
n=0;
for(i=0; i<count;i++) {
flag = 0;
for(j=0; j<el.count;j++)
if (element[i]==el.element[j]) flag=l; if(flag==0) {tmp.element[n]=element[i]; n++;}
}
tmp.count=n;
return tmp;
}
Set& Set::operator=(Set el)
{
count=el. count;
for(int i=0; i<count;i++) element[i]=el.element[i]; return *this;
bool Set::operator==(Set el)
{
int flag;
if (el.count!=count) return false;
for(int i=0; i<count;i++)
{
flag = 0;
for(int j=0; j<el.count;j++)
if (element[i]==el.element!]]) flag=l; if (flag==0) return false;
}
return true;
bool Set::operator<(Set el)
{
if (count<=el.count) return true;
else
return false;
int main()
{
int menu; Set setl, set2;
SetConsoleOutputCP( 1251);
while (1)
{
cout"\n\nMEHK)\n"; 
cout"l. Ñôîðìèðîâ*òü ì*îæåñòâî\ï"; cout"2. Äîá*âèòü ýëåìå*ò\ï"; cout"3. Óä*ëèòü ýëåìå*ò\ï"; cout"4. Ïåðåñå÷å*èå ì*îæåñòâ\ï"; cout"5. Îáúåäè*å*èå ì*îæåñòâ\ï"; cout"6. Ð*ç*îñòü ì*îæåñòâ\ï"; cout"7. Ïåðåïðèñâ*èâ**èå ì*îæåñòâ\ï"; cout"8. Ñð*â*å*èå ** ð*âå*ñòâî ì*îæåñòâ\ï"; cout"9. Ñð*â*å*èå ** *åð*âå*ñòâî ì*îæåñòâ\ï"; cout"10. Âûõîä\ï\ï\ï";
ñîØ"Âûáåðèòå ïó*êò ìå*þ: ";
cinmenu;
if (menu=10) exit(O);
switch(menu)
{
case 1: {setl.set(); break;}
case 2: {set 1 .addElementQ; ñîØ"Ðåçóëüò*ò\ï"; setl .get(); break;} case 3: {setl,delElement(); ñîèÊ<"Ðåçóëüò*ò\ï"; setl .get(); break;} case 4: {setl.set(); set2.set(); setl = setl*set2;
cout"Pe3ynbTaT\n";setl.get(); break; } case 5: {setl ,set(); set2.set(); setl = setl+set2;
ñîØ"Ðåçóëüò*ò\ï";5åÈ^å1(); break; } case 6: {setl .set(); set2.set(); setl = setl-set2;
cout"Pe3ynbTaT\n";setl.get(); break; } case 7: {setl .setQ; set2 = setl;
ñîèÊ<"Ðåçóëüò*ò\ï";5å12^å1(); break; } case 8: {setl.set(); set2.set();
if (setl==set2) ñîè1"Ì*îæåñòâ* ð*â*û";
else ñîØ"Ì*îæåñòâ* *å ð*â*û"; break; } case 9: {setl .set(); set2.set();
if (setl<set2) ñîèÊ<"Ïåðâîå ì*îæåñòâî ìå*üøå âòîðîãî";
else ñîØ"Ïåðâîå ì*îæåñòâî áîëüøå âòîðîãî"; break; } default:{cout"TaKoro ïó*êò* ìå*þ *åò. Ïîâòîðèòå ââîä "; break;}
} }
return 0; 
¹13 (ïîäð*çäåë 3.3)
Ñîçä*òü *áñòð*êò*ûé á*çîâûé êë*ññ Integer (öåëîå) ñ âèðòó*ëü*ûìè *ðèô ìåòè÷åñêèìè îïåð*öèÿìè è ôó*êöèåé âûâîä* ** ýêð**. Îïðåäåëèòü ïðîèçâîä*ûå êë*ññû Decimal (äåñÿòè÷*îå) è Binary (äâîè÷*îå), ðå*ëèçóþùèå ñîáñòâå**ûå *ðèôìåòè÷åñêèå îïåð*öèè è ôó*êöèþ âûâîä* ** ýêð**. ×èñëî ïðåäñò*âëÿåòñÿ ì*ññèâîì, ê*æäûé ýëåìå*ò êîòîðîãî - öèôð*.
Ðåøå*èå
#include <iostream.h> #include <windows.h> #include <string.h>
class Integer {
public:
int figure[32], count;
virtual void sum(){}; //âèðò. ô. ñóììû
virtual void diff(){}; //âèðò. ô. ð*ç*îñòè
virtual void pro(){}; //âèðò. ô. ïðîèçâåäå*èÿ
virtual void input(){}; //âûâîä
virtual void output(){}; //ââîä
};
//                  
class Decimal : Integer
{
public:
void input()
{
char decimal[32]; int j;
for(int i=0; i<32; i++) figure[i]=0; ñîè1"Ââåäèòå äåñÿòè÷*îå ÷èñëî: "; cindecimal; count=strlen(decimal); j=count-l;
for(i=31; i>31-count; i)
{
figure[i]=decimal[j]-48;
void output()
{
for(int j=0; (j<32)&&(figure[j]==0); j++); for(int i=j; i<32; i++) coutfigure[i]; coutendl;
void sum()
{
Decimal decimal2; decimal2.input(); for (int i=31; i>0; i--) 
{
figure[i]+=decimal2.figure[i]; figurefi-1 ]+=figure[i]/l 0; figure[i] %=10;
}
ñî1È"Ðåçóëüò*ò"; output();
void diff()
!
Decimal decimal2; decimal2.input();
for (int i=31; i>0; i-) {
if (figure[i]>=decimal2.figure[i]) figure[i]-=decimal2.figure[i];
else
{
figure[i]=figure[i]-decimal2.figure[i]+10;
figure[i-l]-=l;
}
}
cout" Ðåçóëüò*ò";
output(); }
void pro()
{
Decimal d2; d2.input();
int i, j, S, P; //S - Ìåñòî äëÿ ôîðìèðîâ**èÿ äâóõ öèôð Ñ-Ð*çðÿä ïåðå*îñ* Decimal W; //ðåçóëüò*ò
if (count>d2.count) W.count=count; else W.count=d2.count; for(i=0; i<32; i++) W.figure[i]=0;
for (i=0; i<32; i++) // Ïî öèôð*ì ÷èñë* d2
{
P=0; // Ñ**÷*ë* ïåðå*îñ* *åò
for (j = 0; j<32; j++) //Ïî öèôð*ì ÷èñë* d
{
S = figure[i]* d2.figure[j]+W.figure[i+j]+P;
W.figure[i+j] = S%10; // Âðåìå**îå ç**÷å*èå î÷åðåä*îé öèôðû Ð = S/10; //Ôîðìèðîâ**èå ð*çðÿä* ïåðå*îñ*
}
W.figure[j+i] = Ð; //Ñò*ðø*ÿ öèôð* ÷*ñòè÷*îãî ïðîèçâåäå*èÿ
}
W.output();
//  -  
class Binary : Integer
{
public:
void inputQ
{ 
char binary[32]; int j;
for(int i=0; i<32; i++) figure[i]=0; ñîè1"Ââåäèòå äâîè÷*îå ÷èñëî: "; cinbinary; count=strlen(binary); j=count-l;
for(i=31; i>31 -count; i--)
{
if(binary[j]-48==0 || binary[j]-48==l)
{
figure[i]=binary[j]-48; j--;
}
else {
figure[i]=l; j-S
}
}
void output()
{
for(int j=0; (j<32)&&(figure[j]==0); j++); for(int i=j; i<32; i++) coutfigure[i]; coutendl;
void sum()
{
Binary b2; b2.input();
for (int i=31; i>0; i-) {
figure[i]+=b2.figure[i]; figure[i-1 ]+=figure[i]/2; figurefi] %=2;
}
ñîèÊ<"Ðåçóëüò*ò";
output(); }
void diff() {
Binary b2; b2.input();
for (int i=31; i>0; i~) {
if (figure[i]>=b2.figure[i]) figure[i]-=b2.figure[i];
else {
figure[i]=figure[i]-b2.figure[i]+2;
figure[i-l]-=l;
}
}
cout" Ðåçóë üò*ò"; 
output();
}
void pro()
{
Decimal d2; d2.input();
int i, j, S, P; //S - Ìåñòî äëÿ ôîðìèðîâ**èÿ äâóõ öèôð Ñ-Ð*çðÿä ïåðå*îñ* Decimal W; //ðåçóëüò*ò
if (count>d2.count) W.count=count; else W.count=d2.count; for(i=0; i<32; i++) W.figure[i]=0;
for (i=0; i<32; i++) // Ïî öèôð*ì ÷èñë* d2
{
P=0; // Ñ**÷*ë* ïåðå*îñ* *åò
for (j = 0; j<32; j++) //Ïî öèôð*ì ÷èñë* d {
S = figure[i]* d2.figure[j]+W.figure[i+j]+P;
W.figure[i+j] = S%10; // Âðåìå**îå ç**÷å*èå î÷åðåä*îé öèôðû
Ð = S/10; //Ôîðìèðîâ**èå ð*çðÿä* ïåðå*îñ*
}
W.figure[j+i] = Ð; //Ñò*ðø*ÿ öèôð* ÷*ñòè÷*îãî ïðîèçâåäå*èÿ
}
W.output();
}
// -  -      
main()
f
int menu; Decimal dl; Binary bl;
SetConsoleOutputCP( 1251);
while (1)
{
ñîèÊ<"\ïÄåìî*ñòð*öèÿ ð*áîòû ñ êë*ññîì äåñÿòè÷*ûõ ÷èñåë\ï"; cout"l. ñëîæå*èå\ï"; cout"2. âû÷èò**èå\ï"; cout"3. óì*îæå*èå\ï";
ñîè1"\ïÄåìî*ñòð*öèÿ ð*áîòû ñ êë*ññîì äâîè÷*ûõ ÷èñåë\ï"; cout"4. ñëîæå*èå\ï"; cout"5. âû÷èò**èå\ï"; cout"6. óì*îæå*èå\ï";
cout"\n7. âûõîä\ï";
ñîØ"Ñäåë*éòå âûáîð: ";
cinmenu;
if (menu==7) exit(0);
switch(menu) {
case 1: {dl.inputQ; dl.sumQ; break;}
case 2: {dl.inputQ; dl.diff(); break;}
case3: {dl.input(); dl.pro(); break:}
case4: {bl.input(); bl.sumQ; break;}
case 5: {bl.input(); bl.diffQ; break;}
case 6: {bl.input(); bl.pro(); break;}
default:{cout"TaKoro ïó*êò* ìå*þ *åò\ï"; break;}
} }
return 0; return 0; 
J^II ^ïîäð*çäåë j.-tj
Ñîçä*òü ø*áëî* êë*ññ* äëÿ ð*áîòû ñ êîìïëåêñ*ûìè ÷èñë*ìè, îáåñïå÷èâ*þùèé âûïîë*å*èå îïåð*öèé ñëîæå*èÿ, âû÷èò**èÿ è óì*îæå*èÿ êîìïëåêñ*ûõ ÷èñåë. Í*ïèñ*òü ïðîãð*ììó, èñïîëüçóþùóþ ýòîò ø*áëî*, ç*ä*â*ÿ âåùåñòâå**óþ è ì*èìóþ ÷*ñòè ê*ê ÷èñë*ìè òèï* double, ò*ê è öåëûìè ÷èñë*ìè.
Ðåøå*èå
#include <iostream.h> #include <windows.h> #include <math.h>
template <elass Type> class Complex
{
public:
Type Real, Image;
void add(Complex); //ôó*êöèÿ ñëîæå*èÿ void sub(Complex); //ôó*êöèÿ âû÷èò**èÿ void mul(Complex); //ôó*êöèÿ óì*îæå*èÿ void del(Complex); //ôó*êöèÿ äåëå*èÿ void Output();
void Input();
};
//îïðåäåëå*èå ôó*êöèé äëÿ êë*ññ* Complex
template <class Type> void Complex<Type>::add(Complex C2)
{
Real = Real + C2.Real; Image = Image + C2.Image ; Output();
}
template <class Type> void Complex<Type>:: sub(Complex C2) {
Real=Real -C2.Real; Image=Image -C2.Image ; Output();
template <class Type> void Complex<Type>:: mul(Complex C2)
{
Real=Real *C2.Real -Image *C2.Image; Image=Real*C2.Image+Image *C2.Real; OutputQ;
template <class Type> void Complex<Type>::del(Complex C2) {
Real=(Real *C2.Real+Image *C2.Image)/(pow(C2.Real,2)+pow(C2.Image,2)); Image=(-l)*(Real *C2.Image +Image *C2.Real)/(pow(C2.Real,2)+pow(C2.Image,2)); OutputQ;
template <class Type> void Complex<Type>::Input()
{
ñîØ"Ââåäèòå äåéñòâèòåëü*óþ ÷*ñòü ÷èñë*: "; cinReal;
ñîØ"Ââåäèòå ì*èìóþ ÷*ñòü ÷èñë*: "; cinImage;
}
template <class Òóðå> void Complex<Type>::Output() {
cout"Ðåçóëüò*ò: "Real"+x*"Imageendl; }
//îñ*îâ**ÿ ïðîãð*ìì*
main() {
int menu;
Complex<int> cintl, cint2; Complex<float> cfloatl, cfloat2; SetConsoleOutputCP( 1251);
while (1)
{
ñîèÊ<"\ïÄåìî*ñòð*öèÿ ð*áîòû ñ öåëûìè ÷èñë*ìè\ï";
cout"l. ñëîæå*èå\ï";
cout"2. âû÷èò**èå\ï";
cout"3. óì*îæå*èå\ï";
cout"4. äåëå*èå\ï";
ñîèÊ<"\ïÄåìî*ñòð*öèÿ ð*áîòû ñ âåùåñòâå**ûìè ÷èñë*ìè\ï";
cout"5. ñëîæå*èå\ï";
cout"6. âû÷èò**èå\ï";
cout"7. óì*îæå*èå\ï";
cout"8. äåëå*èå\ï";
cout"\n9. âûõîä\ï";
ñîèÊ<"Ñäåë*éòå âûáîð: ";
cinmenu;
if (menu==9) exit(O);
switch(menu) {
case 1: {cintl.Input(); cint2.Input(); cintl.add(cint2); break;} case 2: {cintl.Input(); cint2.Input(); cintl.sub(cint2); break;} case 3: {cintl.InputQ; cint2.Input(); cintl,mul(cint2); break;} case 4: {cintl.Input(); cint2.Input(); cintl.del(cint2); break; } case 5: {cfloatl .Input(); cfloat2.Input(); cfloatl ,add(cfloat2); break;} case 6: {cfloatl .Input(); cfloat2.Input(); cfloatl .sub(cfloat2); break;} case 7: {cfloatl .Input(); cfloat2.Input(); cfloatl ,mul(cfloat2); break;} case 8: {cfloatl .Input(); cfloat2.Input(); cfloatl ,del(cfloat2); break;} default: {ñîÙ"Ò*êîãî ïó*êò* ìå*þ *åò\ï"; break;}
} }
return 0; return 0; x
30
... ...400 ... ......

3
, ....

37
, ... :
, , .... ?

22 29
, ....... ?
C++
1
ListItem*ref->first = new ListItem;
--------------------------
:
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
# include <iostream>
#include <string>
using namespace std;
class List
{
public:
    struct ListItem
    {
        
        string punkt;
        int nomer;
        string FIO;
        int den;
        int mesac;
        int god;
        ListItem *Next;
    };
 
    ListItem *First;
public:
    List(){
        First=NULL;
    }
    List(ListItem *a)
    {
        First=a;
    }
ListItem* addx (ListItem *a)//     
{
    ListItem * ref=new ListItem;
    ref->den=a->den;
    ref->god=a->god;
    ref->mesac=a->mesac;
    ref->nomer=a->nomer;
    ref->punkt=a->punkt;
    ref->FIO=a->FIO;
        return First;
}
ListItem*addx()//     
{
ListItem*ref->first = new ListItem;
    //string str;
    getline(cin,str);
    cout<<"\n    :\n";
    getline(cin,str);
    ref->FIO=str;
    cout<<"\n  :\n";
    getline(cin,str);
    ref->punkt=str;
    cout<<"\n  :\n";
    cin>>ref->nomer;
    cout<<"\n :\n\t:";
    cin>>ref->den;
    cout<<"\n\t:";
    cin>>ref->mesac;
    cout<<"\n\t:";
    cin>>ref->god;
    End = ref;
    return First;
}
void List::InsertFirst(ListItem *w)//   
{
    ListItem *a=new ListItem;
    a->punkt=w->punkt;
    a->nomer=w->nomer;
    a->FIO=w->FIO;
    a->mesac=w->mesac;
    a->den=w->den;
    a->god=w->god;
    a->Next=First;
    First=a;
}
void deleteThis (ListItem *a)//  
{
    try
    {
    ListItem *A=new ListItem;
    A=NULL;
    ListItem *p=new ListItem;
    ListItem *i=new ListItem;
    p=First;
    i=p->Next;
    if((p->FIO==a->FIO)&&(p->nomer==a->nomer)&&(p->den==a->den)&&(p->mesac==a->mesac)&&(p->god==a->god))
    {
        First=First->Next;
        delete  p;
    }
    else
    {
        while (i!=NULL)
        {
            if((i->FIO==a->FIO)&&(i->nomer==a->nomer)&&(i->den==a->den)&&(i->mesac==a->mesac)&&(i->god==a->god))
                A=p;
            
            p=p->Next;
            i=i->Next;
            
        }
        ListItem *tmp=A->Next;
        if (tmp==NULL)
            throw " ,   !\n";
        
        A->Next=tmp->Next;
        delete tmp;
    }
}
catch (char*)
{cout<<" ,   !\n";}
}
void PrintData(int d,int m,int g)//   
{
    int c=0;
    ListItem *q;
    q=First;
    if (q==NULL)
        cout<<" !\n";
    else
        while (q!=0)
        {
            if((q->den==d)&&(q->mesac==m)&&(q->god==g))
            {
                cout<<q->FIO<<endl<<q->punkt<<endl<<q->nomer<<endl<<q->den<<"."<<q->mesac<<"."<<q->god<<"\n********\n";
                c++;
            }
            q=q->Next;
        }
        if(c==0)
        {
            cout<<"  !\n";
        }
}
void PrintList()//  
{
 
    ListItem *p=First;
    int n=1;
    if(p==NULL)
        cout<<" \n";
    else
        while(p)
        {   
            cout<<n<<":"<<p->FIO<<endl<<p->punkt<<endl<<p->nomer<<endl<<p->den<<"."<<p->mesac<<"."<<p->god<<"\n********\n";
            n++;
            p=p->Next;
        }
}
};
int main()
{
    setlocale (LC_ALL,".1251");
    List:: ListItem a={"",876,"",17,10,2010};
    List::ListItem b={"",123,"MMM",17,8,2009};
    List::  ListItem *r,*y;
    r=&a;
    y=&b;
    List t;
    List list1;
    list1.PrintList();
    list1.addx;
    list1.addx;
    list1.PrintList();
    cout<<" \n";
    list1.addx(y);
    list1.PrintList();
    cout<<" \n";
    list1.deleteThis;
    list1.PrintList();
    cout<<" \n";
    list1.PrintData(17,8,1990);
    cout<<"**********************************\n";
    t.PrintList();
    list1.PrintList();
    cout<<"***********NEW**********\n";
    list1.addx();//    
    list1.addx();
    list1.PrintList();
    return 0;
}
14
.... .(

29
correct
, .
:
" ". , :
- ,
- ,
- ,
- .
:
- ,
- ,
- ,
- ,
- .
-----------------------------------------------
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
# include <iostream>
#include <string>
using namespace std;
class List
{
public:
    struct ListItem
    {
        
        string punkt;
        int nomer;
        string FIO;
        int den;
        int mesac;
        int god;
        ListItem *Next;
    };
 
    ListItem *First;
public:
    List(){
        First=NULL;
    }
    List(ListItem *a)
    {
        First=a;
    }
ListItem* addx (ListItem *a)//     
{
    ListItem * ref=new ListItem;
    ref->den=a->den;
    ref->god=a->god;
    ref->mesac=a->mesac;
    ref->nomer=a->nomer;
    ref->punkt=a->punkt;
    ref->FIO=a->FIO;
        return First;
}
ListItem*addx()//     
{
ListItem*ref->first=new ListItem;
    //string str;
    getline(cin,str);
    cout<<"\n    :\n";
    getline(cin,str);
    ref->FIO=str;
    cout<<"\n  :\n";
    getline(cin,str);
    ref->punkt=str;
    cout<<"\n  :\n";
    cin>>ref->nomer;
    cout<<"\n :\n\t:";
    cin>>ref->den;
    cout<<"\n\t:";
    cin>>ref->mesac;
    cout<<"\n\t:";
    cin>>ref->god;
    End = ref;
    return First;
}
void List::InsertFirst(ListItem *w)//   
{
    ListItem *a=new ListItem;
    a->punkt=w->punkt;
    a->nomer=w->nomer;
    a->FIO=w->FIO;
    a->mesac=w->mesac;
    a->den=w->den;
    a->god=w->god;
    a->Next=First;
    First=a;
}
void deleteThis (ListItem *a)//  
{
    try
    {
    ListItem *A=new ListItem;
    A=NULL;
    ListItem *p=new ListItem;
    ListItem *i=new ListItem;
    p=First;
    i=p->Next;
    if((p->FIO==a->FIO)&&(p->nomer==a->nomer)&&(p->den==a->den)&&(p->mesac==a->mesac)&&(p->god==a->god))
    {
        First=First->Next;
        delete  p;
    }
    else
    {
        while (i!=NULL)
        {
            if((i->FIO==a->FIO)&&(i->nomer==a->nomer)&&(i->den==a->den)&&(i->mesac==a->mesac)&&(i->god==a->god))
                A=p;
            
            p=p->Next;
            i=i->Next;
            
        }
        ListItem *tmp=A->Next;
        if (tmp==NULL)
            throw " ,   !\n";
        
        A->Next=tmp->Next;
        delete tmp;
    }
}
catch (char*)
{cout<<" ,   !\n";}
}
void PrintData(int d,int m,int g)//   
{
    int c=0;
    ListItem *q;
    q=First;
    if (q==NULL)
        cout<<" !\n";
    else
        while (q!=0)
        {
            if((q->den==d)&&(q->mesac==m)&&(q->god==g))
            {
                cout<<q->FIO<<endl<<q->punkt<<endl<<q->nomer<<endl<<q->den<<"."<<q->mesac<<"."<<q->god<<"\n********\n";
                c++;
            }
            q=q->Next;
        }
        if(c==0)
        {
            cout<<"  !\n";
        }
}
void PrintList()//  
{
 
    ListItem *p=First;
    int n=1;
    if(p==NULL)
        cout<<" \n";
    else
        while(p)
        {   
            cout<<n<<":"<<p->FIO<<endl<<p->punkt<<endl<<p->nomer<<endl<<p->den<<"."<<p->mesac<<"."<<p->god<<"\n********\n";
            n++;
            p=p->Next;
        }
}
};
int main()
{
    setlocale (LC_ALL,".1251");
    List:: ListItem a={"",876,"",17,10,2010};
    List::ListItem b={"",123,"MMM",17,8,2009};
    List::  ListItem *r,*y;
    r=&a;
    y=&b;
    List t;
    List list1;
    list1.PrintList();
    list1.addx;
    list1.addx;
    list1.PrintList();
    cout<<" \n";
    list1.addx(y);
    list1.PrintList();
    cout<<" \n";
    list1.deleteThis;
    list1.PrintList();
    cout<<" \n";
    list1.PrintData(17,8,1990);
    cout<<"**********************************\n";
    t.PrintList();
    list1.PrintList();
    cout<<"***********NEW**********\n";
    list1.addx();//    
    list1.addx();
    list1.PrintList();
    return 0;
}
,!
... .. , ?
MoreAnswers
37091 / 29110 / 5898
: 17.06.2006
: 43,301
04.01.2013, 23:20     , TEMPLATE
:

C++ . : missing template arguments before v
template C++
'MyQueue' : use of class template requires template argument list C++



:
Buildog
40 / 40 / 2
: 29.04.2012
: 185
04.01.2013, 23:20     , TEMPLATE #20
, inline, private , inline void List::InsertFirst
Yandex
04.01.2013, 23:20     , TEMPLATE

: 06:42. GMT +3.
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
@Mail.ru