.


:




:

































 

 

 

 


5 || (|): struct, union, enum




. ++

' . .

|| ( |):

struct _

{

, -

};

' ; || }. || _, , , , :

_ ;

_* ;

, || .

|| , || .

. , || : _볺 _.

# include < iostream. h>

void main ()

{ struct client {

char name [15];

int sum;

}; // client

client mas [10]; // 10 client

int i, num; //

cin >> num;

for (i = 0; i < num; i++)

{ cout << ¢¢ \ n ¢¢

cin >> mas [i].name; // name

cout << ;

cin >> mas [i].sum; / / sum

} }

|| || ||, ¢¢.¢¢ ( ).

|',| (|| ), ||

__ > __

*:

| (*__). __

|| ', , , || . || . |',| . || || .

. ||, || || , LIFO(last input, first output ,- ).

#include <iostream.h>

#include <process.h>

#include <conio.h>

// boolean

enum boolean{true, false};

// struct

struct stack{

char s;

stack* p;

};

 

// typedef Stk,

// stack*

typedef stack* Stk;

Stk stk;

 

// reset() () ,

//

Stk reset()

{

return NULL;

}

 

// push(char c, Stk top) , , //, stack //

Stk push(char c, Stk top)

{ stk=new stack;

if(stk==NULL){ cout<<"\n ";

exit(1);}

stk->s=c;

if(top!=NULL) stk->p=top;

return stk;

}

 

/* pop(Stk top) , , , , , , , ( )*/

Stk pop(Stk top)

{ cout<<top->s;

stk=top;

top=top->p;

delete stk;

return top->p;

}

 

// empty(const Stk top) , ,

// false,

boolean empty(const Stk top)

{ return (boolean)(top==NULL);

}

 

void main()

{ clrscr();

Stk top;

char str[]="fghg hfgt dtdt dtyd dtyf";

int i=0;

cout<<str<<endl;

top=reset();

while(str[i])

top=push(str[i++],top);

while(!empty(top))

top=pop(top);

getch();

}

' (union) struct. ᒺ , |,| , , || union struct. ֳ || |. ' | ', . ' '|| ', '. ( ).

|| | enum || , , || (enumerators). , , struct, union. , |,| || . || || ||:
_=.

 





:


: 2016-07-29; !; : 329 |


:

:

, ,
==> ...

1638 - | 1630 -


© 2015-2024 lektsii.org - -

: 0.01 .