Программирование >>  Расширенная версия языка c++ 

1 ... 158 159 160 [ 161 ] 162 163 164 ... 227


2. ttinclude <iostream> #include <ctime> using namespace std;

stack::-stack(}

free(stck);

щение ствола в стек void stack: :pu5h (cfiar ch)

if (tos-Size) {

cout Стек полон \n ; return;

.stck[tos] = ch; , ...

tos++;

Выталкивание ствола из стека char stack::pop ()

{

if (tos=0) {

cou Стек пуст \n ;

return 0; возврат нуля при стом стеке

tos-;

return

int main О

образование двух, автоматически инициализируемых, стеков stack si(10) , s2(10) ;

int i;

sl.push( a) ;

s2.push(x ) ; * . :- .

sl.push(b) ; s2.push(y);

si.push ( c) ; :

s2.push(z);

for(i=0; i<3; i++) cout атвол из стека si: sl.popO \n ;

for(i=0; i<3; i++) cout ошвол из стека s2: s2.pop() \n ;

return 0;



class

time t systime; public:

t and d(tiiae t t) ; конструктор void show() ;

t and d: ; t and d (t ime tt)

systime = t;

void t and d::Ehow()

cout << ctime(usystime);

..if ~

time t x; x = time (NULL) ; t and dob(x) ; ob.show() ;

return 0;

. J-

3. linclude <iostreain>

using namespace

class box (

double 1 w, h;

double

public:

box (double a, double b, double c),-voidvol ( ) ; ,

box: :box (double a, double b, double c)

t. ;-.-(;. -.1.1. t... .

1 = a;

w = b; h - c;

volume - 1 * w * h;



Приложение В, Ответы на вопросы и решения упражнений void box г :vol()

cou Объе volume \n ;

int main ()

box x(2.2, 3.97, 3.09), y(1.0, 2.0, 3.0);

X . vol(); y.vol0 ;

return 0;

1. ttinclude <iostream>

using namespace std;

class area cl { public 1

double height; double width;

class rectangle: public (

public:

rectangle (double h, double w) ; double

class isosceles: public area cl { public:

isosceles (double h, double w} ; double

rectangle:: rectangle (doubleh, double w)

height = h; width = w;

isosceles::isosceles (double h, double w) {

height = h;

width = w;



1 ... 158 159 160 [ 161 ] 162 163 164 ... 227

© 2006 - 2025 pmbk.ru. Генерация страницы: 0
При копировании материалов приветствуются ссылки.
Яндекс.Метрика