ᒺ ++

ᒺ- C++: , , , . ++. . . ᒺ. . ˳ .

,
14.03.2013
144,3 K

. ,

, , , , .

http://www.allbest.ru/

C++ - , . ++ .

, , ++ , . , .

. ' , . , , '. ' '-. , .

C++ . - , ' , , . , , , , , ' .

'- :

;

;

;

.

, :

publk - , - ;

protected - - - ;

prvate- - .

.

, , .

, , , , - , , , . , - .

(, ' , ). ³ , . , 򳺿 ', 䳿.

- . , , -, - , , , 䳿, -, ', .

'

++ ' , . - -. - , ( ' ). - , . ' ++ :

class className

{

publc:

//

//

protected:

//

//

};

man ( )

{

className obj

obj.<' >

}

' class, ' . .

, nlne-.

- , . ' '. ' , .

' , , ' '.

. , ' , . publc. ', .

'- '. , ' , - , ' , ' '.

'- ++.

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

p p . graphcs.h #nclude<graphcs.h>. graphcs.lb, ( ), ( ).

(graphdrver & graphmode). , ' .

, :

- ;

- ;

- ;

- ..

, , , . BOS 䳺.

, , , , (EGA,VGA,...).

Turbo C Borland C++ Borland cono.h , .

.

'

, :

.

NotePad .

++ (BCv3.1).

exe- .

.

: , , . , , . , , .

class Text

prvate :

nt dx - .

nt dy - .

nt style - .

nt color - .

nt sze - .

publc :

char str[80] - char, .

Text(char *s) - .

nt Length() {return strlen(str);} - nlne-, .

vod set(nt a, nt b, nt c, nt d, nt e) - .

vod show() - .

class Knopka -

nt x1 - x .

nt y1 - y .

nt x2 - x .

nt y2 - y .

nt color - .

Publc :

statc posx - .

statc posy - .

Text *txt - ' Text.

vod show(nt act) - .

vrtual vod run(vod) - , .

vod set(nt c) - .

~Knopka() {delete txt;} - .

nt Knopka::posx = 0 - .

nt Knopka::posy = 0 - .

class knopka1:publc Knopka

publc :

vod run(vod) - .

class knopka2: publc Knopka {

publc: vod run(vod) - .

class knopka3 : publc Knopka {

publc: vod run (vod) - .

class knopka4:publc Knopka {

publc: vod run(vod) - .

class knopka5:publc Knopka {

publc: vod run(vod) - .

class Menu

knopka1 kn1 - ' knopka1.

knopka2 kn2 - ' knopka2.

knopka3 kn3 - ' knopka3.

knopka4 kn4 - ' knopka4.

knopka5 kn5 - ' knopka5.

Knopka *maskn[5] - knopka.

nt x - .

nt y - .

nt nomAct - .

nt vertc - , .

nt actTextCol - .

nt actBgCol - .

nt pasTextCol - .

nt pasBgCol - .

vod Fon() - .

vod show(vod) - .

vod onLeft(vod) - .

vod onRght(vod) - .

vod onDown(vod) - .

publc :

Menu(); - .

~Menu() { closegraph(); delete maskn;} - .

vod getmessage(nt msg) - .

char *flename1 = "nkut.dat" - ' , .

char *flename2 = "length.dat" - -//-

class Pont - ' ,.

frend class programm - programm Pont

nt x; - .

nt y; - .

publc :

nt getx() {return x;}; - .

nt gety() {return y;}; - .

vod setx(nt xx) {x = xx;}; - .

vod sety(nt yy) {y = yy;}; - .

class programm - ' .

frend class Pont;

Pont *pP - ' Pont.

nt nP - .

nt S - , .

nt color - .

nt length(nt , nt j) - , .

publc :

programm() - .

vod Run() - .

~programm() - .

˳

menu.cpp:

#nclude <stdo.h>

#nclude <process.h>

#nclude <graphcs.h>

#nclude <strng.h>

#nclude <cono.h>

#defne LEFT 75

#defne RGHT 77

#defne ENTER 13

#defne UP 72

#defne DOWN 80

const char *flename = "pryama.cpp";

class Text

{

prvate:

nt dx;

nt dy;

nt style;

nt color;

nt sze;

publc:

char str[80];

Text(char *s);

nt Length() {return strlen(str);};

vod set(nt a, nt b, nt c, nt d, nt e);

vod show();

};

Text::Text(char *s)

{

strcpy(str,s);

}

vod Text::set(nt a, nt b, nt c, nt d, nt e)

{

dx = a;

dy = b;

style = c;

color = d;

sze = e;

}

vod Text::show()

{

setcolor(color);

settextstyle(style,HORZ_DR, sze);

outtextxy(dx,dy,str);

}

class Knopka {

nt x1;

nt y1;

nt x2;

nt y2;

nt color;

publc:

statc posx;

statc posy;

Text *txt;

vod show(nt act);

vrtual vod run(vod)=0;

vod set(nt c);

~Knopka() {delete txt;};

};

nt Knopka::posx = 0;

nt Knopka::posy = 0;

vod Knopka::set(nt c)

{

color = 9;

nt ln = txt->Length()*12+10;

x1 = posx;

x2 = posx + ln;

y1 = posy;

y2 = posy + 30;

f (c)

{

posy = y2+10;

}

else

{

posx=x2+5;

}

txt->set(x1+5,y1+(y2-y1)/2-(y2-y1)/4,1,15,1);

}

vod Knopka::show(nt act)

{

f (act)

{

setfllstyle(1,7);

txt->show();

bar(x1,y1,x2,y2);

}

else

{

setfllstyle(1,color);

txt->show();

bar(x1,y1,x2,y2);

}

txt->show();

}

class knopka1:publc Knopka {

publc:

vod run(vod);

};

vod knopka1::run(vod)

{

setcolor(4);

settextstyle(8,0,4);

outtextxy(200,150," ");

setcolor(7);

settextstyle(8,0,2);

outtextxy(120,250,". . 2-00");

setcolor(5);

settextstyle(8,0,3);

outtextxy(360,250," ..");

getch();

};

class knopka2: publc Knopka {

publc: vod run(vod);

};

vod knopka2::run()

{

restorecrtmode();

nt result = spawnl(P_WAT, "c:\\wnnt\\notepad.exe","", "pont.dat", NULL);

f (result == -1)

{

perror("Error execute");

getch();

}

setgraphmode(getgraphmode());

}

class knopka3 : publc Knopka {

publc: vod run (vod);

};

vod knopka3::run()

{

restorecrtmode();

nt result = spawnle(P_WAT, "d:\\bc\\bn\\bc.exe", "", flename, NULL);

f (result == -1)

{

perror("Error execute");

getch();

}

setgraphmode(getgraphmode());

}

class knopka4:publc Knopka {

publc: vod run(vod);

};

vod knopka4::run()

{

restorecrtmode();

char str[50];

strcpy(str,flename);

str[strlen(str)-1] = 'e';

str[strlen(str)-2] = 'x';

str[strlen(str)-3] = 'e';

nt result = spawnle(P_WAT, str, NULL, NULL);

f (result == -1)

{

perror("Error execute");

getch();

}

setgraphmode(getgraphmode());

}

class knopka5:publc Knopka {

publc: vod run(vod);

};

vod knopka5::run (vod)

{

closegraph();

ext(0);

}

class Menu {

knopka1 kn1;

knopka2 kn2;

knopka3 kn3;

knopka4 kn4;

knopka5 kn5;

Knopka *maskn[5];

nt x;

nt y;

nt nomAct;

nt vertc;

nt actTextCol;

nt actBgCol;

nt pasTextCol;

nt pasBgCol;

vod Fon();

vod show(vod);

vod onLeft(vod) ;

vod onRght(vod) ;

vod onDown(vod) ;

publc:

Menu();

~Menu() { closegraph(); delete maskn;};

vod getmessage(nt msg);

};

vod Menu::Fon()

{

setfllstyle(1, 1);

bar(0,0,getmaxx(),getmaxy());

}

vod Menu::onLeft(vod)

{

nomAct=(nomAct==0) ? 4: (nomAct-=1);

}

vod Menu::onRght(vod)

{

nomAct=(nomAct==4) ? 0 : (nomAct+=1);

}

vod Menu::onDown(vod)

{

maskn[nomAct]->run();

Fon();

}

vod Menu::show(vod)

{

for(nt =0;<5;++)

f (==nomAct)

maskn[]->show(1);

else

maskn[]->show(0);

}

Menu::Menu()

{

FLE *f;

f ((f = fopen("menu.dat", "rt")) == NULL)

{

prntf("Confg fale for menu not read, press any key to ext");

getch();

ext(1);

}

nt gdrver = DETECT, gmode, errorcode;

ntgraph(&gdrver, &gmode, "");

errorcode = graphresult();

f (errorcode != grOk)

{

prntf("Graphcs error: %s\n", grapherrormsg(errorcode));

getch();

ext(1);

}

maskn[0] = &kn1;

maskn[1] = &kn2;

maskn[2] = &kn3;

maskn[3] = &kn4;

maskn[4] = &kn5;

char *s;

nt =0;

nt ret = 1;

whle (ret)

{

nt par;

fscanf(f,"%s = %d\n",s,&par);

f (strstr("x1",s) != NULL) maskn[0]->posx = par;

f (strstr("y1",s) != NULL) maskn[0]->posy = par;

f (strstr("vertkal",s) != NULL)

{

vertc = par;

ret = 0;

}

}

whle (!feof(f))

{

fgets(s,255,f);

f (s[0]=='&')

{

s[strlen(s)-1]='\0';

char *str;

str = &s[1];

maskn[]->txt = new Text(str);

maskn[]->set(vertc);

++;

}

}

fclose(f);

nomAct = 0;

Fon();

show();

}

vod Menu::getmessage(nt msg)

{

swtch(msg){

case LEFT: onLeft();

show();

break;

case UP: onLeft();

show();

break;

case RGHT:

onRght();

show();

break;

case DOWN:

onRght();

show();

break;

case ENTER:

onDown();

show();

break;

default:

break;

}

}

vod man()

{

Menu *mnu = new Menu;

whle(1) mnu->getmessage(getch());

}

pryama.cpp:

#nclude <stdo.h>

#nclude <math.h>

#nclude <stdlb.h>

#nclude <cono.h>

#nclude <graphcs.h>

char *flename1 = "nkut.dat";

char *flename2 = "length.dat";

class Pont

{

nt x;

nt y;

publc:

frend class programm;

nt r;

nt getx() {return x;};

nt gety() {return y;};

vod setx(nt xx) {x = xx;};

vod sety(nt yy) {y = yy;};

Pont();

};

Pont::Pont()

{

r = 0;

}

class programm

{

frend class Pont;

Pont *pP;

nt nP;

nt S;

nt color;

nt length(nt , nt j);

publc:

programm();

vod Run();

~programm();

};

nt programm::length(nt , nt j)

{

nt l = nt(sqrt(double(pP[].x-pP[j].x)*(pP[].x-pP[j].x)+double(pP[].y-pP[j].y)*(pP[].y-pP[j].y)));

return l;

}

programm::programm()

{

FLE *f1,*f2;

color = 15;

nP = 0;

f ((f1 = fopen(flename1, "rt")) == NULL)

{

prntf("Confg fle not read, press any key to ext");

getch();

ext(1);

}

whle (!feof(f1))

{

fscanf(f1,"x = %d, y = %d\n");

nP++;

}

rewnd(f1);

pP = new Pont[nP];

nt x,y;

nt = 0;

whle (!feof(f1))

{

fscanf(f1,"x = %d, y = %d\n",&x,&y);

pP[].setx(x);

pP[].sety(y);

++;

}

fclose(f1);

f ((f2 = fopen(flename2, "rt")) == NULL)

{

prntf("Confg fle not read, press any key to ext");

getch();

ext(1);

}

fscanf(f2,"l = %d",&S);

fclose(f2);

}

vod programm::Run()

{

nt max;

for (nt =0; <nP; ++)

for (nt j=1; j<nP; j++)

f (!=j)

{

f (==0 && j==1) max = length(,j);

f (length(,j)>max)

max = length(,j);

}

max /= 2;

for (=0; <nP; ++)

for (nt j=1; j<nP; j++)

{

nt l=length(,j);

f (l<S && !=j)

pP[].r = max-80;

}

for (=0; <nP; ++)

{

setcolor(3);

f (pP[].r != 0)

crcle(pP[].getx(),pP[].gety(),pP[].r);

for (nt j=1; j<nP; j++)

f (!=j && pP[].r != 0 && pP[j].r != 0 && length(,j)<(pP[].r+pP[j].r))

{

setcolor(12);

crcle(pP[].getx(),pP[].gety(),pP[].r);

}

}

moveto(pP[0].getx(),pP[0].gety());

for (=1; <nP; ++)

{

setcolor(color);

lneto(pP[].getx(),pP[].gety());

}

lneto(pP[0].getx(),pP[0].gety());

}

programm::~programm()

{

delete(pP);

}

vod man()

{

nt gdrver = DETECT,gmode;

ntgraph(&gdrver, &gmode, "");

programm pr;

pr.Run();

getch();

closegraph();

}

˳

menu.dat:

x1 = 10

y1 = 10

vertkal = 0

&Help

&Edt

&BC

&Program

&Ext

nkut.dat:

x = 100, y = 100

x = 250, y = 80

x = 310, y = 150

x = 320, y = 350

x = 180, y = 250

length.dat:

l = 93

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

Borland C++ 4.5. 1,2 . 1996.

. ++ . 1996.

. , Borland C++ . 1996.

Allbest.ru


  • ++ '- . , , , . . .

    [102,5 K], 14.03.2013

  • ++: , . . ᒺ- . .

    [510,9 K], 14.03.2013

  • NotePad . '- . '. .

    [69,4 K], 14.03.2013

  • , ᒺ- , , , .

    [155,4 K], 18.12.2011

  • . ' C++, . - "", , ᒺ- .

    [117,8 K], 14.03.2013

  • ᒺ- ++. ᒺ- . 㳿 . classProgressBar. font. .

    [211,3 K], 19.08.2010

  • ++ ᒺ- , , , . ᒺ. ˳ .

    [104,4 K], 14.03.2013

  • '- . ++. . .

    [98,0 K], 06.05.2014

  • ++. . , . , . .

    [41,0 K], 17.02.2009

  • NotePad . C++ , . . ᒺ- .

    [123,3 K], 14.03.2013

, , ..
PPT, PPTX PDF- .
.