用C语言编分形的程序找不到#include<graphics.h>怎么办?
画分形函数的程序,从某个课本上抄的.请达人帮个忙~~~#include<stdio.h>#include<graphics.h>#include<complex.h>#i...
画分形函数的程序,从某个课本上抄的.请达人帮个忙~~~
#include<stdio.h>
#include<graphics.h>
#include<complex.h>
#include<conio.h>
#include<math.h>
#define MAX 1024
complex a[MAX];
int num=5;
Koch(num)
{
int i;
complex t[MAX];
if(num==0)a[0]=complex(-300,0),a[1]=complex(300,0);
else
{
Koch(num-1);
for(i=0;i<=pow(4,num-1);i++)
t[i]=a[i];
for(i=0;i<pow(4,num-1);i++)
{
a[i*4]=t[i];
a[i*4+1]=t[i]+(t[i+1]-t[i])*(1.0/3);
a[i*4+3]=t[i]+(t[i+1]-t[i])*(2.0/3);
a[i*4+2]=t[i]+(t[i+1]-t[i])*complex(0.5,sqrt(3)/6);
}
a[i*4]=t[i];
}
}
complex CH(complex pt)
{return(complex(real(pt)+0.5*getmaxx(),-imag(pt)+0.5*getmaxy()));}
void draw(num)
{
int i;
for(i=0;i<pow(4,num);i++)
line(real(CH(a[i])),imag(CH(a[i])),
real(CH(a[i+1])),imag(CH(a[i+1]));
}
void main()
{
int i,gd,gm;
gd=DETECT;
setbkcolor(1);
setcolor(14);
initgraph(&gd,&gm,"");
for(i=0;i<=num;i++)
{
Koch(i);
clearviewport();
draw(i);
getch();
}
closegraph();
} 展开
#include<stdio.h>
#include<graphics.h>
#include<complex.h>
#include<conio.h>
#include<math.h>
#define MAX 1024
complex a[MAX];
int num=5;
Koch(num)
{
int i;
complex t[MAX];
if(num==0)a[0]=complex(-300,0),a[1]=complex(300,0);
else
{
Koch(num-1);
for(i=0;i<=pow(4,num-1);i++)
t[i]=a[i];
for(i=0;i<pow(4,num-1);i++)
{
a[i*4]=t[i];
a[i*4+1]=t[i]+(t[i+1]-t[i])*(1.0/3);
a[i*4+3]=t[i]+(t[i+1]-t[i])*(2.0/3);
a[i*4+2]=t[i]+(t[i+1]-t[i])*complex(0.5,sqrt(3)/6);
}
a[i*4]=t[i];
}
}
complex CH(complex pt)
{return(complex(real(pt)+0.5*getmaxx(),-imag(pt)+0.5*getmaxy()));}
void draw(num)
{
int i;
for(i=0;i<pow(4,num);i++)
line(real(CH(a[i])),imag(CH(a[i])),
real(CH(a[i+1])),imag(CH(a[i+1]));
}
void main()
{
int i,gd,gm;
gd=DETECT;
setbkcolor(1);
setcolor(14);
initgraph(&gd,&gm,"");
for(i=0;i<=num;i++)
{
Koch(i);
clearviewport();
draw(i);
getch();
}
closegraph();
} 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询