- Page 2 and 3: До сегашните компю
- Page 4 and 5: В паметта на компют
- Page 8 and 9: Тази редица от числ
- Page 10 and 11: Съществуват стотиц
- Page 12 and 13: Тези езици не са не
- Page 14 and 15: Означението {…} има
- Page 16 and 17: 2Основни елементио
- Page 18 and 19: е коментар в езика C
- Page 20 and 21: Забележка: При опис
- Page 22 and 23: cout
- Page 24 and 25: грешка съдържа ном
- Page 26 and 27: Всяка програма на C+
- Page 28 and 29: {int cout = 21;return 0;}е доп
- Page 30 and 31: Задача2. Да се напиш
- Page 32 and 33: ОПab5.65 8.3Чрез операт
- Page 34 and 35: начин на действие с
- Page 36 and 37: Когато програмата
- Page 38 and 39: const е запазена дума
- Page 40 and 41: Задача 5. Напишете п
- Page 42 and 43: потребителски дефи
- Page 44 and 45: Оператор за логиче
- Page 46 and 47: - Прилагането на оп
- Page 48 and 49: Аритметични операт
- Page 50 and 51: (в частност цяла ко
- Page 52 and 53: Целите числа се изв
- Page 54 and 55: 123.3454 -10343.034 123Е13 -1.23е
- Page 56 and 57:
==!=>>== 0 е trueДопълнен
- Page 58 and 59:
Компилаторът издав
- Page 60 and 61:
x y1.56 -2.36Операторътco
- Page 62 and 63:
cout
- Page 64 and 65:
- Целите променливи
- Page 66 and 67:
Семантика на аритм
- Page 68 and 69:
double x = 23.56, y = -123.5;bool b
- Page 70 and 71:
int main(){int a, b;cin >> a >> b >
- Page 72 and 73:
а) ln(x 4 + e x + 10) б) log 5 (x
- Page 74 and 75:
Допълнителна литер
- Page 76 and 77:
• Ако е от тип double,
- Page 78 and 79:
допустим е операто
- Page 80 and 81:
cout
- Page 82 and 83:
4.3. БлокЧесто синта
- Page 84 and 85:
- if (ако) е запазена
- Page 86 and 87:
Program Zad18.cpp#include int main(
- Page 88 and 89:
cout > c;if (!cin){cout
- Page 90 and 91:
4. Операторът if () ; els
- Page 92 and 93:
Правило: Всяко else с
- Page 94 and 95:
}cout > c;if (!cin){cout
- Page 96 and 97:
където с i е означен
- Page 98 and 99:
Операторът switch реа
- Page 100 and 101:
Програмистът съзна
- Page 102 and 103:
{case 1: y = x - 5; break;case 2: y
- Page 104 and 105:
Състои се от крайно
- Page 106 and 107:
Операции над симво
- Page 108 and 109:
. В този случай, опе
- Page 110 and 111:
2. Символните конст
- Page 112 and 113:
Program Zad46.cpp#include int main(
- Page 114 and 115:
Weekday d1, d2 = SUNDAY;Name a;Name
- Page 116 and 117:
1. d1+d2-4 е цял аритмет
- Page 118 and 119:
}case SATURDAY: cout
- Page 120 and 121:
6Съставни типове да
- Page 122 and 123:
до 3.bool[4] дефинира м
- Page 124 and 125:
ool b[3];enum {FALSE, TRUE} x[20];d
- Page 126 and 127:
адрес - - - адрес - - -н
- Page 128 and 129:
стойности. Освен то
- Page 130 and 131:
if (n < 1 || n > 20){cout
- Page 132 and 133:
Задача 51. Да се напи
- Page 134 and 135:
if (a[i] != a[j]) br++;if (br == n*
- Page 136 and 137:
for (i = 0; i
- Page 138 and 139:
eturn 1;}for (i = 0; i
- Page 140 and 141:
Достъпът до елемен
- Page 142 and 143:
редиците от конста
- Page 144 and 145:
базовият тип изиск
- Page 146 and 147:
{cout m;if (!cin){cout 20){cout
- Page 148 and 149:
}for (j = 0; j
- Page 150 and 151:
…Задача 60. Да се на
- Page 152 and 153:
извеждане на сорти
- Page 154 and 155:
дефинира масива от
- Page 156 and 157:
Забележка: Редицат
- Page 158 and 159:
char r[] = “ab”;са еквив
- Page 160 and 161:
Въвежда от буфера н
- Page 162 and 163:
cout
- Page 164 and 165:
и са произволни ни
- Page 166 and 167:
Допълнение:Конкате
- Page 168 and 169:
- и са низове (конс
- Page 170 and 171:
Пример: Програмния
- Page 172 and 173:
cin >> n;int i;for (i = 0; i
- Page 174 and 175:
cin >> n;for(int i = 0; i
- Page 176 and 177:
програма, която нам
- Page 178 and 179:
Задача 23. Дадена е ц
- Page 180 and 181:
7Типове указател и
- Page 182 and 183:
Променлива величин
- Page 184 and 185:
*СемантикаИзвлича
- Page 186 and 187:
показва, че адресът
- Page 188 and 189:
Следващата програм
- Page 190 and 191:
извежда сумата на м
- Page 192 and 193:
сумиране на двете м
- Page 194 and 195:
би трябвало да заме
- Page 196 and 197:
Пример:...int a = 5;int &syn
- Page 198 and 199:
int i = 125;const int& syni = i;cou
- Page 200 and 201:
дефинирането, обръ
- Page 202 and 203:
eturn x;}Заглавието оп
- Page 204 and 205:
a 140x0066FDF4 ab 210x0066FDF042c0x
- Page 206 and 207:
Операторът за цикъ
- Page 208 and 209:
Функцията swapi има п
- Page 210 and 211:
Изпълнява се като б
- Page 212 and 213:
cout
- Page 214 and 215:
присвоява на a стой
- Page 216 and 217:
cout
- Page 218 and 219:
Синтаксисreturn [] опц
- Page 220 and 221:
на функцията. Ако ф
- Page 222 and 223:
Глобални идентифик
- Page 224 and 225:
int a[20];readarr(n, a);writearr(n,
- Page 226 and 227:
{cout
- Page 228 and 229:
се отнася за масиви
- Page 230 and 231:
проберява дали ред
- Page 232 and 233:
cout
- Page 234 and 235:
Скобите, ограждащи
- Page 236 and 237:
Задача 77. Да се напи
- Page 238 and 239:
if (!cin){cout 10){cout m;if (!ci
- Page 240 and 241:
Пример: В следващат
- Page 242 and 243:
ЗадачиЗадача 1. Въп
- Page 244 and 245:
Задача 8. Даден е тр
- Page 246 and 247:
Забележка: Скобите,
- Page 248 and 249:
където a и b са даден
- Page 250 and 251:
Задача 81. Да се напи
- Page 252 and 253:
където с ⊗ е означе
- Page 254 and 255:
осъществи чрез опе
- Page 256 and 257:
cin >> x;if (!cin){cout
- Page 258 and 259:
cout
- Page 260 and 261:
⎧n−1⎪x.x, n > 0nx = ⎨ 1, n
- Page 262 and 263:
В този случай намир
- Page 264 and 265:
път (Временно спира
- Page 266 and 267:
if (c >= '0' && c > op;y = formula(
- Page 268 and 269:
cout
- Page 270 and 271:
eturn 0;}bool way(int x, int y){if
- Page 272 and 273:
Задача 93. Да се напи
- Page 274 and 275:
} while (n < 1 && n > 20);int i, j;
- Page 276 and 277:
} while (i < 0 || i > 9 || j < 0 ||
- Page 278 and 279:
for (int l = 0; l
- Page 280 and 281:
{s++;x[s] = i;if (p == 1){s++;x[s]
- Page 282 and 283:
съседни във вертик
- Page 284 and 285:
11Структури11.1 Струк
- Page 286 and 287:
име price от тип double и
- Page 288 and 289:
Примери:1. Множеств
- Page 290 and 291:
а с b1, s1 и y -b1.name - от
- Page 292 and 293:
- Възможно е формал
- Page 294 and 295:
{print_student(table[i]);cout
- Page 296 and 297:
Достъпът до полета
- Page 298 and 299:
}}...За работа със ст
- Page 300 and 301:
at quotrat(rat& r1, rat& r2) // д
- Page 302 and 303:
{cout
- Page 304 and 305:
int den;void makerat(int a, int b);
- Page 306 and 307:
{while (a!=b)if (a > b) a = a-b; el
- Page 308 and 309:
int denom();void printrat();};Оп
- Page 310 and 311:
{cout marks[i];}}void student::pri
- Page 312 and 313:
Задача 7. Да се напи
- Page 314 and 315:
while(y2>x2){y1++;y2=y2-x2;}{ψ(x1,
- Page 316 and 317:
присвояване, услов
- Page 318 and 319:
Забележка. Ако опер
- Page 320 and 321:
1. Проверява се дали
- Page 322 and 323:
y1=0; y2=x1;while (y2>=x2){y1++;y2=
- Page 324 and 325:
получаваме ¬ B: a 2 ≤n
- Page 326 and 327:
a≥0 ∧ a 2 ≤n
- Page 328 and 329:
else b=x;}Получихме пет
- Page 330 and 331:
където a съдържа n-т
- Page 332 and 333:
така че да е в сила
- Page 334 and 335:
S0: i=0;j=1;z=x[0]!=x[1];От ус
- Page 336 and 337:
z=x[i]!=x[j];}else{i++;j=i+1;z=x[i]
- Page 338 and 339:
f1(i,n,j) = (i+j)/2g1(n,f1(n,i,j),j
- Page 340 and 341:
Тя реализира двоич
- Page 342 and 343:
От тях получаваме:S1
- Page 344 and 345:
Задача 8. Да се синт
- Page 346 and 347:
+ / 9 7 - 28 5Задачат
- Page 348 and 349:
Задачата за правил
- Page 350 and 351:
if (t[j] != ' '){i++;s[i] = t[j];}l
- Page 352 and 353:
cin.getline(t, 100);len = strlen(t)
- Page 354 and 355:
- Ако на някоя стъпк
- Page 356 and 357:
} while (m[0][0] != '0');}void writ
- Page 358 and 359:
for (j = 0; j > m[i][j];} while (m[
- Page 360 and 361:
}bool member(int x, int n, int* a){
- Page 362 and 363:
{smin = s + 1;for (int i = 0; i 10
- Page 364 and 365:
::= 0|1|...|9и ако това е
- Page 366 and 367:
14КласовеКласовете
- Page 368 and 369:
- промяна на стойно
- Page 370 and 371:
at q(2,5);инициализира
- Page 373 and 374:
Нещо повече, освен
- Page 375 and 376:
void rat::print() const{cout
- Page 377 and 378:
at();rat(int, int);void read();int
- Page 379 and 380:
[:] опц () const; ::= private |
- Page 381 and 382:
{cout get_numer()
- Page 383 and 384:
Нека декларираме к
- Page 385 and 386:
на всяко място в па
- Page 387 and 388:
Пример:void f(int i, int* p){
- Page 389 and 390:
обектите, инициали
- Page 391 and 392:
void rat::print(){cout
- Page 393 and 394:
double x;double y;public:point(doub
- Page 395 and 396:
class Point{public:void Read();doub
- Page 397 and 398:
{} ::= се определя ка
- Page 399 and 400:
Пример: Ще дефинира
- Page 401 and 402:
at::rat(){numer = 0;denom = 1;}14.4
- Page 403 and 404:
t(2); // t се инициализ
- Page 405 and 406:
свързва с числител
- Page 407 and 408:
Обръщението sum(p1, q1).
- Page 409 and 410:
{int a;int table[10];public:int arr
- Page 411 and 412:
int get_score() const;private:char
- Page 414 and 415:
{cout
- Page 416 and 417:
void push(int);void pop();int top()
- Page 418 and 419:
Използването на ди
- Page 420 and 421:
отделя памет в хийп
- Page 422 and 423:
За да се разруши ма
- Page 424 and 425:
създават в динамич
- Page 426 and 427:
Използвана е глоба
- Page 428 and 429:
заделя памет за дин
- Page 430 and 431:
Накрая, чрез операт
- Page 432 and 433:
Този избор на дестр
- Page 434 and 435:
б) инициализаторът
- Page 436 and 437:
{name = new char[strlen(p.name)+1];
- Page 438 and 439:
на изпълнението на
- Page 440 and 441:
public функции на дост
- Page 442 and 443:
int numer;int denom;public:rat(int=
- Page 444 and 445:
Предефиниране чрез
- Page 446 and 447:
startNULLstart inf link5 NULLstart
- Page 448 and 449:
{elem* p = start;start = new elem;s
- Page 450 and 451:
}else start = NULL;}Класът st
- Page 452 and 453:
start = start->link;delete p;return
- Page 454 and 455:
int formula(){char c, x, y, op;stac
- Page 456 and 457:
съответните фактич
- Page 458 and 459:
Дефинирането на чл
- Page 460 and 461:
#include template struct elem{T inf
- Page 462 and 463:
start->link = p;}template int stack
- Page 464 and 465:
Последната ще бъде
- Page 466 and 467:
link = NULL;}int inf;item* link;};
- Page 468 and 469:
class item{friend class stack;priva
- Page 470 and 471:
while (p){s = new item;s->inf = p->
- Page 472 and 473:
a^n*b^m(a-b)*(a+b)(a+b)*c-d*f+m^pan
- Page 474 and 475:
if (s[i] >= '0' && s[i]
- Page 476 and 477:
st.push(z);}i++;}st.pop(z);return z
- Page 478 and 479:
15.2 Опашка15.2.1 Дефин
- Page 480 and 481:
queue& operator=(queue const &); //
- Page 482 and 483:
Включваме този шаб
- Page 484 and 485:
queue& queue::operator=(queue const
- Page 486 and 487:
дефиниране на клас
- Page 488 and 489:
нарича сентинел. То
- Page 490 and 491:
cout > n;for (i = 0; i < n; i++){co
- Page 492 and 493:
cin >> s.name;cout > s.age;q1.Inser
- Page 494 and 495:
указател къмначало
- Page 496 and 497:
Следващите две фун
- Page 498 and 499:
void LList::print(){elem *p = Start
- Page 500 and 501:
End->link = NULL;if (Current) Curre
- Page 502 and 503:
{int n = 0;IterStart();elem *p = It
- Page 504 and 505:
while (p != Start){temp = p->link;p
- Page 506 and 507:
void main(){LList l1;l1.ToEnd(1);l1
- Page 508 and 509:
}илиvoid deleteall(int a, IntLis
- Page 510 and 511:
}}д) void print_reverse(IntList l)
- Page 512 and 513:
}}return l;Задача 145. Да
- Page 514 and 515:
{l.ToEnd(p->inf);p = l1.Iter();}els
- Page 516 and 517:
l.IterStart();elem *p = l.Iter();if
- Page 518 and 519:
Задача 148. Да се нап
- Page 520 and 521:
#include "L-List.cpp"typedef LList
- Page 522 and 523:
Да се напишат следн
- Page 524 and 525:
else{pol ed;ed.pow = pp->inf.pow;ed
- Page 526 and 527:
eturn s;}double x;typedef LList DLi
- Page 528 and 529:
Задача 152. Да се нап
- Page 530 and 531:
Програма Zad153.cpp реш
- Page 532 and 533:
15.3.4.1 Реализация на
- Page 534 and 535:
elseif (!Start) Current = NULL;else
- Page 536 and 537:
while (q->link != p) q = q->link;q-
- Page 538 and 539:
l.IterStart();elem *p = l.Iter();wh
- Page 540 and 541:
{l.ToEnd(p->inf);p = l1.Iter();}whi
- Page 542 and 543:
Конструктора и чле
- Page 544 and 545:
{elem *p = End;while (p){cout inf p
- Page 546 and 547:
}else{p->pred->succ = p->succ;p->su
- Page 548 and 549:
{p = l.IterSucc();q = l.IterPred();
- Page 550 and 551:
Задача 6. Железопът
- Page 552 and 553:
в) търси данни за ст
- Page 554 and 555:
Посоката на линиит
- Page 556 and 557:
(инфиксен) запис на
- Page 558 and 559:
{T inf;node *Left,*Right;};Двои
- Page 560 and 561:
{pos = NULL;if (r){pos = new node;p
- Page 562 and 563:
cout Right);}Записваме т
- Page 564 and 565:
Program Zad163.cpp#include #include
- Page 566 and 567:
Задача 166. Да се нап
- Page 568 and 569:
print_tree(t.RightTree());cout
- Page 570 and 571:
ool member(T a, tree const&t){if (t
- Page 572 and 573:
KKLR- X = където - X =L L’X
- Page 574 and 575:
}template void BinOrdTree::DeleteTr
- Page 576 and 577:
template void BinOrdTree::Create(){
- Page 578 and 579:
elseif (a == x && RightTree().empty
- Page 580 and 581:
template void BinOrdTree::pr1(const
- Page 582 and 583:
не е идеално баланс
- Page 584 and 585:
Ребрата (дъгите) мо
- Page 586 and 587:
определят класа IntGr
- Page 588 and 589:
е:p = p->link;}cout n;for (int i
- Page 590 and 591:
}while (p->link) p = l.Iter();l.Del
- Page 592 and 593:
::= |( ); ::= +|-|*|/; ::= 0|1|...
- Page 594 and 595:
Дефинирането на пр
- Page 596 and 597:
Декларациите на ко
- Page 598 and 599:
usp = u;}void Student::PrintStudent
- Page 600 and 601:
PeopleStudentPStudentКласът P
- Page 602 and 603:
};int d3();· Ако базовия
- Page 604 and 605:
public-компонента d3(),
- Page 606 and 607:
d2d3d4d5d6d7d8d9d10d11d12a9()a12()a
- Page 608 and 609:
char * name;char * egn;};void Peopl
- Page 610 and 611:
Student, тъй като после
- Page 612 and 613:
· Достъп на функции
- Page 614 and 615:
d2: 200a2: 300a3():a1: 10a2: 300Щ
- Page 616 and 617:
class base: bx = 5class der: bx = 1
- Page 618 and 619:
При единично насле
- Page 620 and 621:
der(int x, int y, int z, int t) : b
- Page 622 and 623:
клас. Конструктори
- Page 625 and 626:
· Основният клас им
- Page 627 and 628:
cout
- Page 629 and 630:
клас, след това се и
- Page 631 and 632:
strcpy(name, str);egn = new char[11
- Page 633 and 634:
Fac.nomer: 42444Uspeh: 6Tax: 4567~P
- Page 635 and 636:
People(char * = “”, char * =
- Page 637 and 638:
обикновените конст
- Page 639 and 640:
конструктор за при
- Page 641 and 642:
~People()~People()Инициали
- Page 643 and 644:
Student::Student(char *str, char *
- Page 645 and 646:
{cout
- Page 647 and 648:
основния клас, ако
- Page 649 and 650:
d32 = d31;cout
- Page 651 and 652:
}People::~People(){delete name;dele
- Page 653 and 654:
#include class People{public:People
- Page 655 and 656:
}return *this;}void Student::PrintS
- Page 657 and 658:
class der : public base{public:der(
- Page 659 and 660:
указателя pd към der м
- Page 661 and 662:
ase *pb = pd; // неявно пр
- Page 663 and 664:
Задача 164. Да се деф
- Page 665 and 666:
private:T col;};template ColPoint1:
- Page 667 and 668:
- Компилиране на де
- Page 669 and 670:
Атрибутите за обла
- Page 671 and 672:
конструктор. В този
- Page 673 and 674:
създава за der конст
- Page 675 and 676:
Чрез обект на произ
- Page 677 and 678:
E(int x = 5){e = x;}void f() const{
- Page 679 and 680:
class Car{public:Car(char * = "", u
- Page 681 and 682:
egn = new char[11];strcpy(egn, p.eg
- Page 683 and 684:
единственото му пр
- Page 685 and 686:
Като производни на
- Page 687 and 688:
void C::print() const{A::print();co
- Page 689 and 690:
Derived member-function f() in a pa
- Page 691 and 692:
cout
- Page 693 and 694:
Как използването н
- Page 695 and 696:
void A::print_own() const{cout
- Page 697 and 698:
Задача 166. Да се деф
- Page 699 and 700:
}void B::print() const{A::print();c
- Page 701 and 702:
}void main(){D d("Mimi", "Toni", "L
- Page 703 and 704:
Пример: В следващат
- Page 705 and 706:
изпълнява се Print() н
- Page 707 and 708:
{col = c;}virtual void Print() cons
- Page 709 and 710:
От тук следва, че не
- Page 711 and 712:
{public:void print() const{cout
- Page 713 and 714:
}//...};class Mouse : public ZooAni
- Page 715 and 716:
Base::pub();Base::pro();}public:vir
- Page 717 and 718:
отново са коментир
- Page 719 and 720:
Логическата структ
- Page 721 and 722:
1 B. Stroustrup, C++ Programming La
- Page 723 and 724:
Променете програма
- Page 725 and 726:
int main(){Point2 p2;p2.ReadPoint2(
- Page 727 and 728:
class derder: public der{public:voi
- Page 729 and 730:
B(int n);};B::B(){cout
- Page 731 and 732:
{b=0;}B::B(int n){b = n;}void B:: p
- Page 733 and 734:
Възможно ли е конст
- Page 735 and 736:
cout
- Page 737:
cout
- Page 740 and 741:
};void main(){void (base::*pb)()con
- Page 742 and 743:
void main(){C c1;C c2(2,4,6,1.0);}
- Page 744 and 745:
{x = new char[strlen(p.x)+1];strcpy
- Page 746 and 747:
{if (this != &p){A::operator=(p);de
- Page 748 and 749:
{virtual void f(){cout
- Page 750:
}измислете и други