.


:




:

































 

 

 

 


14.




: , .

// 14.1. , , .

#include <graphics.h> //

//

#include <conio.h>

#include <stdio.h>

#include <stdlib.h>

#include <dos.h>

void init_graph() //

{ int gr_driver, //

gr_mode, //

error_code; //

gr_driver = DETECT; //

initgraph(&gr_driver, &gr_mode, "c:\\bc31\\bgi");

error_code = graphresult();

if (error_code!= grOk) //...,

printf(" : %s", grapherrormsg(error_code));

exit(1); //

} // init_graph()

void main()

{ int Pause = 500, //

X = 50, Y = 100, //

XX = 550, YY = 450;

clrscr(); gotoxy(1,10);

printf("\n\t , ");

printf("\n\t ");

getch(); // - !

init_graph(); getch();

//

//

setfillstyle(SOLID_FILL,RED); //

bar(X-5,Y-5,XX+5,YY+5); //

getch(); //

setfillstyle(SOLID_FILL,GREEN); //

bar(X,Y,XX,YY); //

getch();

setviewport(X+5,Y+5,XX-5,YY-5, 1); //

//

setbkcolor(BLUE); //

setcolor(WHITE); getch(); //

clearviewport(); getch(); //

//

int Font, //

CharSize, // i;

for (Font=0; Font < 5; Font++) //

for (i=1; i <= 5; i++) //

{ clearviewport();

CharSize = 2*i;

settextstyle(Font, HORIZ_DIR, CharSize); // ,
//

settextjustify(CENTER_TEXT, CENTER_TEXT); //

//

outtextxy(250,175,"BbC"); //

delay(Pause); //

} getch();

//

int Pattern; //

for (Pattern=0; Pattern <= 11; Pattern++)

{ clearviewport();

setfillstyle(Pattern,WHITE); //

circle((XX-X)/2,(YY-Y)/2,YY/3); //

// ((XX-X)/2,(YY-Y)/2) YY/3

floodfill((XX-X)/2,(YY-Y)/2, WHITE); // ,
// ((XX-X)/2,(YY-Y)/2)

delay(Pause+200);

} getch();

//

int LineType;

clearviewport();

setwritemode(COPY_PUT); //

for (LineType=0, i=0; LineType < 5; LineType++)

{ setlinestyle(LineType,0,1); // :

// , , (1 = NORM_WIDTH, 3 = THICK_WIDTH)

line(5,15+15*i,500,15+15*i); i++; //

setlinestyle(LineType,0,3);

line(5,15+15*i,500,15+15*i); i++; //

delay(Pause);

} getch();

closegraph();

}

 

// 14.2. // y = exp(-k*x)*sin(x), k = 0.1*j, j = 1,2,...,5

#include <graphics.h>

#include <conio.h>

#include <stdio.h>

#include <stdlib.h>

#include <dos.h>

#include <math.h>

// !!! init_graph() 1

main()

{ int i, j Pause = 500, //

X0, Y0, //

dy; // Y

double x, y, //

DE=0.1;

clrscr(); gotoxy(1,10);

printf("\n\t , ");

printf("\n\t ");

getch(); // - !

init_graph();

X0 = 20; Y0 = getmaxy() / 2; //

setbkcolor(BLACK); setcolor(WHITE);

line(X0,20,X0,getmaxy()-20); // Y

line(X0,Y0,getmaxx()-20,Y0); //

settextjustify(RIGHT_TEXT,CENTER_TEXT); // a Y

// c

settextstyle(DEFAULT_FONT,VERT_DIR,1); // 88,

// , 1

dy = (Y0-20) / 2; // Y

// Y

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

{ moveto(X0-5,20+i*dy);

switch (i)

{ case 0: { outtext("1.0"); break; }

case 1: { outtext("0.5"); break; }

case 2: { outtext("0"); break; }

case 3: { outtext("-0.5"); break; }

case 4: { outtext("-1.0"); break; }

}

} getch();

//

for (j = 0; j <= 5; j++) //

{ moveto(X0,Y0);

for (i = 1; i < getmaxx()-40; i++) //

{ x = i*4*M_PI/(getmaxx()-40);

y = exp(-DE*j*x)*sin(x);

lineto(X0+i, Y0-int(y*220));

} getch();

} getch();

closegraph();

}

// 14.3.

// :

// increment.

// :

// "Y" - (" "),

// "N" - .

#include <graphics.h>

#include <conio.h>

#include <stdio.h>

#include <stdlib.h>

#include <dos.h>

#include <math.h>

#include <ctype.h> // toupper() -

//

// !!! init_graph() 1

main()

{ int i, k, increment = 0, Pause = 100,

arr[10] = {310,230,330,230,330,250,310,250,310,230};

// ,

//

char ch;

clrscr(); gotoxy(1,10);

printf("\t ");

printf("\n\t Y, - N");

ch = getch(); ch = toupper(ch);

init_graph();

setbkcolor(BLACK); setcolor(WHITE);

drawpoly(5,arr); //

delay(2*Pause);

if (ch == 'N') //

{ setcolor(BLACK); drawpoly(5, arr); }

for (i = 1; i < 25; i++) //

{ increment++;

for (k = 1; k < 5; k++) //

//

{ switch (k)

{ case 1: { arr[1] = arr[1] - increment;

arr[9] = arr[1]; break; } //

case 2: { arr[2] = arr[2] + increment;

break;} //

case 3: { arr[5] = arr[5] + increment;

break;} //

case 4: { arr[6] = arr[6] - increment;

break;} //

}

setcolor(WHITE);

drawpoly(5, arr);

delay(Pause);

if (ch == 'N') //

{ setcolor(BLACK); drawpoly(5, arr); }

}

} getch(); //

closegraph();

}

 

// 14.4.

#include <graphics.h>

#include <conio.h>

#include <stdio.h>

#include <stdlib.h> //

// malloc() free()

#include <dos.h>

// !!! init_graph() 1

main()

{ int i, size;

void *pnter; //

clrscr(); gotoxy(1,10);

printf("\n\t ");

printf("\n\t ");

getch();

init_graph();

setbkcolor(BLACK);

setcolor(RED); //

setfillstyle(1, RED); //

circle(20, 200, 10); //

floodfill(20, 200, RED); //

size = imagesize(10,190,30,210); // ,

//

pnter = malloc(size); // size

getimage(10,190,30,210, pnter); //

//

getch();

for (i = 1; i < 400; i++) //

{ putimage(10+(i-1), 190, pnter, XOR_PUT); //

//

putimage(10+i, 190, pnter, XOR_PUT); //

delay(5);

} getch();

free(pnter); //

closegraph();

}

1. ?

2. ?

3. , .

4. ?

 


2

ר





:


: 2015-10-01; !; : 540 |


:

:

, ,
==> ...

1473 - | 1391 -


© 2015-2024 lektsii.org - -

: 0.021 .