: , ""

: , ""

. ..

()

:

( )

:

,

( ) ()

,

(...)

:

(...)

. 2008


1.

2.

3. (

4.

5.

6.

7.

8.


1..

- .
- . - , . . ,

: , . ++ class. () ( -), . . (-), (-) . . , . - , .

. , , .

( ). , , . , . . ..

. . . , - , . . class ++. private, public, protected.

. , ++ -. , , . - -. .

.

. ; . , .

. . , . , - . .

. , . , . . . , . . ; .


2. .

++, class . - - , .

, . , , , , . ; ++ struct . . - . , , . ( - ) - . , - , .

++ - - . ++ - .

- . , , , .

- (object). , () . ++ , . . Borland C++ , . ++ . ++ , , . , . ++ . . ,

. , , . .

.

- () , .

struct Zmeja //

{

COORD *t; //

int PCount; //

};

, , . , , .

, . , . .

class Struct :

struct

{

};

. - , . .

.

.

- . , . . .

.

:

:

1)   , . . , .

2)   , ( .

3)   .

, , , , .


4. ( ).

.

1)

2)

3)

4)

5) : .

6) .

7) : , ( ), .

8) : , 3), . .

9)

:

4)   , . . , .

5)   , ( .

6)   .

, , , , .

 

.

GotoXY( ) ,
Level() , ,
Move(Game &g) Game &g
PlusJabloko(Game &g) Game &g
skorostGame(Game &g) Game &g
SetColor(ConsoleColor text, ConsoleColor background) ConsoleColor text, ConsoleColor background
STENA_2()

,

ZmejaStart() GotoXY(10,15)
Main()

.

//

void PlusJabloko(Game &g){}

1..int x,y,i;

Int n=g.gaduka.pCount;

2. do while , -

x = rand() % 56+3; //

y = rand() % 19+3; //

3. -, -.

4. ->break;

5. , -

6.

7. -

8. --> 4(5,6)

printf("%c", 6); //

//

void skorostGame(Game &g){}

1. - -

2. -

3. -

4. -

//

int Move(Game &g){}

1. -

2. -

3. .

4. - - , - -

- -

- ,

5. - ,

-

-

6. -

7. , 1-

8. - -

9.

10. ( )

.

. - .

:

enum ConsoleColor

{

Pink = 0,

Blue = 1,

Green = 2,

Cyan = 3,

Red = 4,

Magenta = 5,

Brown = 6,

LightGray = 7,

DarkGray = 8,

LightBlue = 9,

LightGreen = 10,

LightCyan = 11,

LightRed = 12,

LightMagenta = 13,

Yellow = 14,

White = 15

7, 7.

:

- , (0,0)

- .

:

struct Zmeja //

{ COORD *t; //

int PCount; //

};

enum uprawlenie{LEFT,UP,RIGHT,DOWN}; //

struct Game //-: , , X Y, ,

{

Zmeja gaduka; //

COORD jabloko; //

int dx,dy, //

pause; //

int nap; //

};

.

Void Level()

GotoXY(10,10)

GotoXY(10,11)

<<"Wu nikogda ne wuigraete "<<endl;

<<"eslu ne bydete bdutelnu!!!"<<endl;

Void ZmejaStart() GotoXY(10,15) <<"Soberite 75 Jablok "<<endl;
Void STENA_2()

GotoXY(20,0)

GotoXY(64,2)

GotoXY(64,3)

GotoXY(64,4)

GotoXY(64,5)

GotoXY(64,7)

GotoXY(64,8)

GotoXY(64,9)

GotoXY(64,10)

GotoXY(64,11)

GotoXY(64,13)

GotoXY(64,14)

GotoXY(64,15)

GotoXY(64,16)

GotoXY(2,2)-(2,23)

GotoXY(61,3)-(61,23)

<< "Igra \"Zmejka\" Maiko Ekaterini" <<endl;

<< "Danue:" << endl ;

<< "Jablok:0" << endl ;

<< "Dlina:3"<< endl;

<< "Speed:0" << endl;

<< "Uprawlenie:" << endl;

<< "Esc:Wuxod" << endl;

<< "P:Pause" << endl;

<<"S:Start" << endl;

<<"L:Level" << endl;

<<":Wwerx"<<endl;

<<":Wniz"<<endl;

<<":Wlewo"<<endl;

<<":Wprawo"<<endl;

printf("*");

printf("*");

Void main()

GotoXY(15,1)

GotoXY(15,6)

GotoXY(15,7)

GotoXY(23,1)

<< "Wu wuigrali(maladec!!!)" << endl;

printf( "\n\t\t\t" );

printf( "\n\t\t\t" );

printf("Wu proigrali(xa-xa-xa!!!)\n\n\t\t\t");

:

1. ,;

void GotoXY(int X, int Y)

{

COORD coord = { X, Y };

SetConsoleCursorPosition(hStdOut, coord);

}

2.

struct Zmeja //

{

COORD *t; //

int PCount; //

};

3. -: , , X Y

struct Game ,

{

Zmeja gaduka; //

COORD jabloko; //

int dx,dy, //

pause; //

int nap; //

};

:

1.

GotoXY(15,1); cout << "Wu wuigrali(maladec!!!)" << endl;

GotoXY(15,6);printf( "\n\t\t\t" );

GotoXY(15,7);printf( "\n\t\t\t" );

getch();

getch();

getch();

getch();

getch();

return;

2.

case KONEC:

GotoXY(23,1); printf("Wu proigrali(xa-xa-xa!!!)\n\n\t\t\t");

getch();

return;

break;


5. ++

, .

#include <iostream> //

#include <time.h> //

#include <stdio.h> // printf

#include <windows.h> // HANDLE, ,

#include <conio.h> // kbhit

#include <math.h>

#include <io.h>

#include <iostream>

#include <fcntl.h>

#include <string.h>

#include "stdafx.h"

#include <math.h> //

#include <stdlib.h> // malloc free

using namespace std;

HANDLE hConsole;

//HANDLE hStdout, hStdin;

HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

void GotoXY(int X, int Y)

{

COORD coord = { X, Y };

SetConsoleCursorPosition(hStdOut, coord);

}

//

enum ConsoleColor

{

Pink = 0,

Blue = 1,

Green = 2,

Cyan = 3,

Red = 4,

Magenta = 5,

Brown = 6,

LightGray = 7,

DarkGray = 8,

LightBlue = 9,

LightGreen = 10,

LightCyan = 11,

LightRed = 12,

LightMagenta = 13,

Yellow = 14,

White = 15

};

void SetColor(ConsoleColor text, ConsoleColor background)

struct Zmeja //

{

COORD *t; //

int PCount; //

};

enum uprawlenie{LEFT,UP,RIGHT,DOWN}; //

struct Game //-: , , X Y, ,

{

Zmeja gaduka; //

COORD jabloko; //

int dx,dy, //

pause; //

int nap; //

};

//

void PlusJabloko(Game &g)

{

int i,x,y;

int n = g.gaduka.PCount;

do

{

x = rand() % 56+3; //

y = rand() % 19+3; //

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

{

if(x == g.gaduka.t[i].X && y == g.gaduka.t[i].Y) //

break;

}

}

while(i < n);

g.jabloko.X = x; //

g.jabloko.Y = y; //

SetConsoleCursorPosition(hConsole, g.jabloko); //

SetConsoleTextAttribute(hConsole,0x0c); //

printf("%c", 6); //

}

//

void skorostGame(Game &g)

{

system("cls");

g.gaduka.PCount = 3; //

g.gaduka.t = new COORD [3];//

for(int i = 0; i < 3; i++)

{

g.gaduka.t[i].X = 20 + i;

g.gaduka.t[i].Y = 20;

}

g.dx = 1;

g.dy = 0;

g.pause = 100;//

PlusJabloko(g);//

}

void Level()

{

GotoXY(10,10);cout <<"Wu nikogda ne wuigraete "<<endl;

GotoXY(10,11);cout <<"eslu ne bydete bdutelnu!!!"<<endl;

}

void ZmejaStart()

{

GotoXY(10,15);cout <<"Soberite 75 Jablok "<<endl;

}

void STENA_2()

{

SetColor(LightBlue , Pink);GotoXY(20,0);cout << "Igra \"Zmejka\" Maiko Ekaterini" <<endl;

GotoXY(64,2);cout << "Danue:" << endl ;

GotoXY(64,3);cout << "Jablok:0" << endl ;

GotoXY(64,4); cout << "Dlina:3"<< endl;

GotoXY(64,5); cout << "Speed:0" << endl;

GotoXY(64,7); cout << "Uprawlenie:" << endl;

GotoXY(64,8); cout << "Esc:Wuxod" << endl;

GotoXY(64,9); cout << "P:Pause" << endl;

GotoXY(64,10); cout <<"S:Start" << endl;

GotoXY(64,11); cout <<"L:Level" << endl;

GotoXY(64,13);printf("%c",24);cout <<":Wwerx"<<endl;

GotoXY(64,14);printf("%c",25);cout<<":Wniz"<<endl;

GotoXY(64,15);printf("%c",27);cout<<":Wlewo"<<endl;

GotoXY(64,16);printf("%c",26);cout<<":Wprawo"<<endl;

{

SetColor(LightMagenta , Pink);

GotoXY(2,2);

int m = 0;

for(m = 0; m < 60; m++)

{

printf("*");

}

}

{

GotoXY(2,24);

int m = 0;

for(m = 0; m < 60;m++)

{

printf("*");

}

}

{

GotoXY(2,3); cout << "*"<<endl;

GotoXY(2,4); cout << "*"<<endl;

GotoXY(2,5); cout << "*"<<endl;

GotoXY(2,6); cout << "*"<<endl;

GotoXY(2,7); cout << "*"<<endl;

GotoXY(2,8); cout << "*"<<endl;

GotoXY(2,9); cout << "*"<<endl;

GotoXY(2,10); cout << "*"<<endl;

GotoXY(2,11); cout << "*"<<endl;

GotoXY(2,12); cout << "*"<<endl;

GotoXY(2,13); cout << "*"<<endl;

GotoXY(2,14); cout << "*"<<endl;

GotoXY(2,15); cout << "*"<<endl;

GotoXY(2,16); cout << "*"<<endl;

GotoXY(2,17); cout << "*"<<endl;

GotoXY(2,18); cout << "*"<<endl;

GotoXY(2,19); cout << "*"<<endl;

GotoXY(2,20); cout << "*"<<endl;

GotoXY(2,21); cout << "*"<<endl;

GotoXY(2,22); cout << "*"<<endl;

GotoXY(2,23); cout << "*"<<endl;

}

{

GotoXY(61,3); cout << "*"<<endl;

GotoXY(61,4); cout << "*"<<endl;

GotoXY(61,5); cout << "*"<<endl;

GotoXY(61,6); cout << "*"<<endl;

GotoXY(61,7); cout << "*"<<endl;

GotoXY(61,8); cout << "*"<<endl;

GotoXY(61,9); cout << "*"<<endl;

GotoXY(61,10); cout << "*"<<endl;

GotoXY(61,11); cout << "*"<<endl;

GotoXY(61,12); cout << "*"<<endl;

GotoXY(61,13); cout << "*"<<endl;

GotoXY(61,14); cout << "*"<<endl;

GotoXY(61,15); cout << "*"<<endl;

GotoXY(61,16); cout << "*"<<endl;

GotoXY(61,17); cout << "*"<<endl;

GotoXY(61,18); cout << "*"<<endl;

GotoXY(61,19); cout << "*"<<endl;

GotoXY(61,20); cout << "*"<<endl;

GotoXY(61,21); cout << "*"<<endl;

GotoXY(61,22); cout << "*"<<endl;

GotoXY(61,23); cout << "*"<<endl;

}

}

//

enum {KONEC, STENA, PLUS, MOVE};

int Move(Game &g)

{

int & n = g.gaduka.PCount;

COORD head = g.gaduka.t[n - 1]; //

COORD tail = g.gaduka.t[0]; //

COORD next;

next.X = head.X + g.dx;

next.Y = head.Y + g.dy; //

if(next.X < 3 || next.Y < 3 || next.X > 60 || next.Y > 23)// ?

return STENA;

if(n > 4)

{

for(int i = 0; i < n; i++)

if(next.X == g.gaduka.t[i].X && next.Y == g.gaduka.t[i].Y) // ?

return KONEC;

}

if(next.X == g.jabloko.X && next.Y == g.jabloko.Y)

{

COORD*temp = new COORD[ ++n ]; // 1

for(int i = 0; i < n; i++)

temp[i] = g.gaduka.t[i]; //

temp[n - 1] = next; //

delete [] g.gaduka.t;

g.gaduka.t = temp;

SetConsoleCursorPosition(hConsole,head);

SetConsoleTextAttribute(hConsole, 0x0a); //

printf("*");

SetConsoleCursorPosition(hConsole,next);

SetConsoleTextAttribute(hConsole,0x0a);

printf("%c",1);

PlusJabloko(g);

return PLUS;

}

for(int i = 0; i < n - 1; i++)

g.gaduka.t[i] = g.gaduka.t[i + 1];

g.gaduka.t[n - 1] = next;

SetConsoleCursorPosition(hConsole,tail);//

printf(" ");

SetConsoleCursorPosition(hConsole,head);

SetConsoleTextAttribute(hConsole, 0x0a);//

printf("*");

SetConsoleCursorPosition(hConsole,next);

SetConsoleTextAttribute(hConsole,0x0f); // ( )

printf("%c",1);

return MOVE;

}

void main()

{

hConsole = GetStdHandle(STD_OUTPUT_HANDLE); //

int key = 0, count = 0;

bool Pause=false;

Game g;

skorostGame(g);

STENA_2();

srand(time(0));

bool pause = false;

while(key != 27)

{

while(!kbhit()) //

{

if(Pause==true)

{

Sleep(1);

continue;

}

switch (Move(g))//

{

case PLUS:

++count;

g.pause-=1;

GotoXY(64,2);cout << "Danue:" << endl ;

GotoXY(64,3); cout << "Jablok:" <<count << endl;

GotoXY(64,4); cout << "Dlina:" <<g.gaduka.PCount << endl;

GotoXY(64,5); cout << "Speed:" <<g.pause<< endl;

GotoXY(64,7); cout << "Uprawlenie:" << endl;

GotoXY(64,8); cout << "Esc:Wuxod" << endl;

GotoXY(64,9); cout << "P:Pause" << endl;

GotoXY(64,10); cout <<"S:Start" << endl;

GotoXY(64,11); cout <<"L:Level" << endl;

GotoXY(64,13);printf("%c",24);cout <<":Wwerx"<<endl;

GotoXY(64,14);printf("%c",25);cout<<":Wniz"<<endl;

GotoXY(64,15);printf("%c",27);cout<<":Wlewo"<<endl;

GotoXY(64,16);printf("%c",26);cout<<":Wprawo"<<endl;

if (count == 75)

{

GotoXY(15,1); cout << "Wu wuigrali(maladec!!!)" << endl;

GotoXY(15,6);printf( "\n\t\t\t" );

GotoXY(15,7);printf( "\n\t\t\t" );

getch();

getch();

getch();

getch();

getch();

return;

}

break;

case STENA:

case KONEC:

GotoXY(23,1); printf("Wu proigrali(xa-xa-xa!!!)\n\n\t\t\t");

getch();

return;

break;

}

Sleep(g.pause); //

}

key = getch();

if(key=='P'||key=='p')

Pause=!Pause;

else if(key=='S'||key=='s')

ZmejaStart();

else if(key=='L'||key=='l')

Level();

else if(key==0||key==224)

{

key=getch();

if(key == 72 && g.nap != DOWN)

{

g.nap = UP;

g.dx = 0;

g.dy = -1;

}

else if(key == 80 && g.nap != UP)

{

g.nap = DOWN;

g.dx = 0;

g.dy = 1;

}

else if(key == 75 && g.nap != RIGHT)

{

g.nap = LEFT;

g.dx = -1;

g.dy = 0;

}

else if(key == 77 && g.nap != LEFT)

{

g.nap = RIGHT;

g.dx = 1;

g.dy = 0;

}

}

}

}



5. .


7..

, . , .

, . .

. ,

.

.


8. .

1. ++.: . /. . . :"-",1999.
2. ++. : . /. . :"", 1993 .

3. ++: . / .

.: 1995.

4. : . / .., .., .. , ٸ .. - , , 2000

5. ++ / .,4- : . .:- .: ,2003

6. : . . . /.., ... ., 2006.

7. ++ : . / .. .: - 2004.

8. ++ : . / . .: 2005.

9. C :/ /
., .. , .., .. -: , 2000

10. : /..,3- .-.:-,2006


9..

1


2

1.44 .





2010