1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include <iostream.h>
#include <conio.h>
#include <graphics.h>
int l, grdriver, grmode, eroare;
void fractal(int x, int y, int r)
{if(r>0) {
fractal(x-r, y+r, r/2);
fractal(x-r, y-r, r/2);
fractal(x+r, y-r, r/2);
fractal(x+r, y+r, r/2);
bar(x-r/2, y-r/2, x+r/2, y+r/2); } }
int main() { cout<<"l="; cin>>l;
grdriver=DETECT;
initgraph(&grdriver, &grmode,"");
eroare=graphresult();
if (eroare==grOk)
{ setbkcolor(WHITE);
setfillstyle(SOLID_FILL,RED);
fractal(getmaxx()/2, getmaxy()/2, l);
getch(); }
closegraph();
return 0; }
|