egavga file must be present in C:\tc\bgi path*/
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include "graphics.h"
int ran=0;
void linebreak(int x1, int y1, int x2, int y2, int x3 ,int y3,int n)
{
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x1,y1,x3,y3);
switch(ran%3)
{
case 0: setfillstyle(1,1);
break;
case 1: setfillstyle(1,2);
break;
case 2:setfillstyle(1,4);
break;
}
floodfill((x1+x2+x3)/3,(y1+y2+y3)/3,15);
delay(15);
while(n>0)
{
n--;
linebreak(x1,y1,(x1+x2)/2,(y1+y2)/2,(x3+x1)/2,(y1+y3)/2,n);
linebreak(x2,y2,(x2+x3)/2,(y2+y3)/2,(x2+x1)/2,(y2+y1)/2,n);
linebreak(x3,y3,(x1+x3)/2,(y1+y3)/2,(x2+x3)/2,(y2+y3)/2,n);
}
ran++;
}
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int x1,x2,y1, y2,e,f,i,j,k,l,n;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
printf("enter the no of levels");
scanf("%d",&n);
linebreak(320,30,580,450,60,450,n-1);
getch();
closegraph();
return 0;
}
No comments:
Post a Comment