www.pudn.com > c.rar > HT.C, change:1980-01-01,size:1154b


#include "graphics.h" 
#include "math.h" 
#include "stdlib.h" 
#include "stdio.h" 
#include "float.h" 
#define Randmax 25 
#define Maxcolor 16 
#define Rightx 639 
#define Bottomy 479 
void advancexy(); 
void testsoln(); 
int display(); 
float a[13],x,y,xnew; 
int n=0; 
main() 
{ 
int driver,mode; 
float r; 
int i; 
driver=DETECT; 
initgraph(&driver,&mode,""); 
setbkcolor(0); 
do{ 
if(n==0) 
{ 
x=0.0;y=0.0; 
randomize(); 
for(i=1;i<=12;i++) 
{ 
r=(float)random(164); 
r=floor(r/164*Randmax); 
a[i]=(r-12.0)/10.0; 
} 
} 
advancexy(); 
testsoln(); 
if(n==1000){if(display())break;n=0;cleardevice();} 
 
}while(n<=2000); 
} 
 
void advancexy() 
{ 
xnew=a[1]+x*(a[2]+a[3]*x+a[4]*y)+y*(a[5]+a[6]*y); 
y=a[7]+x*(a[8]+a[9]*x+a[10]*y)+y*(a[11]+a[12]*y); 
x=xnew; 
n++; 
} 
 
int display() 
{ 
int i,j,color; 
for(i=0;i<=Rightx;i++) 
for(j=0;j<=Bottomy;j++) 
{ 
x=-5.0+(float)i/64.0; 
y=5.0-(float)j/48.0; 
n=0; 
while(n<128&&(x*x+y*y)<1000000) 
{advancexy();} 
color=n%Maxcolor; 
putpixel(i,j,color); 
if(kbhit())if(getch()==27) return 1; 
} 
return 0; 
} 
 
void testsoln() 
{ 
if(n==1000)return; 
if((x*x+y*y)>1000000) 
{if(n>128)n=1000; 
else 
n=0; 
} 
}