.


:




:

































 

 

 

 


10. . '




7.

i .

. . , . , ѳ.

1.

.

#include <stdio.h>

#include <conio.h>

#include <stdlib.h>

#include <graphics.h>

#define BGIPATH ":\\borlandc\\bgi"

// , *.bgi. ,

// BGI PATH.

#define ESC 27 // , getch()

#define UP_ARROW 72

#define DOWH_ARROW 80

#define RIGHT_ARROW 77

#define LEFT_ARROW 75

void Initialize ();

void MoveRec ();

int GraphDriver; //

int GraphMode; //

int MaxX, MaxY; //

int MaxColors; //

int ErrorCode; //

void main ()

{

Initialize ();

MoveRec ();

closegraph ();

}

void Initialize ()

{

detectgraph (&GraphDriver, &GraphMode);

initgraph (&GraphDriver, &GraphMode, BGIPATH);

ErrorCode - graphresult ();

if < ErrorCode!= grOk)

{

printf (" : %s\n", grapherrormsg (ErrorCode));

exit (1);

}

MaxColors=getmaxcolor () +1; //

MaxX=getmaxx (); //

MaxY=getmaxy ();

}

void MoveRec ()

{

int i, x, y, x1, y1, x2, y2;

int scalex=1, scaley=1;

setbkcolor (BLUE);

setfillstyle (1, WHITE);

// -

1=MaxX/2 -70; y1=MaxY/2-20;

x2=MaxX/2+70; y2=MaxY/2+20;

bar(x1, y1, 2, 2);

// . <S>

for (i=getch(); i!= ESC; i=getch())

{

if () continue; // -

switch (getch ())

{

case UP_ARROW: x=0; y=-1; break;

case DOWH_ARROW: x=0; y=1; break;

case RIGHT_ARROW: x=1; y=0; break;

case LEFT_ARROW: x=-1; y=0; break;

default: continue;

}

// ?

if ((x1+x*scalex<0) || (x2+x*scalex>MaxX)) x=0;

if ((y1+y*scaley<0) || (y2+y*scaley>MaxY)) y=0;

//

setfillstyle (1, BLUE);

bar (x1, y1, x2, y2);

// ,

setfillstyle (1, RED);

x1+=x*scalex; x2+=x*scalex;

| y1+=y* scaley; 2+= * scaley;

bar (x1, y1, x2, y2);

}

}

 

2.

" ", : , .

#include <stdio.h>

#include <conio.h>

#include <stdlib.h>

#include <graphics.h>

#define BGIPATH ":\\borlandc\\bgi"

void Initialize ();

void Pixel ();

int GraphDriver, GraphMode, MaxX, MaxY, MaxColors, ErrorCode;

void main ()

{

Initialize ();

Pixel ();

closegraph ();

}

void Initialize ()

{

GraphDriver = DETECT; //

initgraph (&GraphDriver, &GraphMode, );

MaxColors=getmaxcolor () + 1;

MaxX = getmaxx (); MaxY = getmaxy ();

}

void Pixel ()

{

int seed= 1000;

int x,, h, w, color;

long int ;

cleadevice ();

rand (seed); //

// 20000

for(=0; <20000; ++)

{

x = 1 + random (X - 1); //

y = 1 + random (Y/2 - 1);

//

color = random (MaxColors);

putpixel (x, , color);

}

//

setviewport (0, MaxY/2, MaxX, MaxY, 1);

rand(seed);

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

{

x = 1 + random (MaxX - 1);

= 1 + random (MaxY - 1);

color = random (MaxColors);

putpixel (x, y, color);

}

getch();

}

 

 

getimage, imagesize, putimage. , ᒺ imagesize.

unsigned far imagesize(int left, int top, int right, int bottom); left, top ;

right, bottom .

getimage . :

void far getimage(int left, int top, int right, int bottom, void far *bitmap);

4 , bitmap (void) , . putimage , getimage. :

void far putimage(int left, int top, void far *bitmap, int op);

left, top ;

bitmap , ;

;

:

COPY_PUT 0 ﳿ

:

XOR_PUT 1

OR_PUT 2 ᒺ

AND_PUT 3

NOT_PUT 4

=0 . =1 .

 

.

1. . .

 

2. . , , ( ). :

/ ( )

;

( ) .

 

3. 20 (100,100).

">" 5 ;

"<" 5 ;

" Ü ", " Ý ", " Þ "," ß ";

.

 

4. . X. . . " " . .

5. . . :

">" 5 ;

"<" 5 ;

"+" 5 ;

"-" 5 ;

" ", " ", " "," "; .

6. . N . K , 1, (N- ). 1, '. .

 

7. ˳. N 3 . . . ³ , , , , . .

8. . : , .

9. . : , .

 

10. . ' .

 





:


: 2016-09-06; !; : 331 |


:

:

: , .
==> ...

1726 - | 1684 -


© 2015-2024 lektsii.org - -

: 0.023 .