潘玮柏的女朋友是吴昕:谁能够用c语言帮我编一个美丽的图形啊?抑或一个数学难题的解决?是歌德巴赫的猜想最好?

来源:百度文库 编辑:高考问答 时间:2024/04/25 07:20:20

# include<graphics.h>
# include<stdlib.h>
# include<time.h>
main()
{
int ran_number,z=1;
float a,b,c,d,e,f;
float x,y;
float x_pre, y_pre;
float disp_x, disp_y;
int gmode, gdriver=DETECT;
initgraph(&gdriver,&gmode,"c:\\tc");
randomize();
x=y=x_pre=y_pre=0;
while(kbhit()==0){
ran_number=random(100)+1;
if(ran_number==1)
{a=0;b=0; c=0; d=0.16; e=0; f=0;}
else if (ran_number>1 && ran_number<=86)
{a=0.85; b=0.04; c=-0.04; d=0.85; e=0; f=1.6;}
else if(ran_number>86 &&ran_number<=93)
{a=0.20; b=-0.26; c=0.23; d=0.22; f=1.6;}
else
{a=-0.15; b=0.28; c=0.26; d=0.24; e=0; f=0.44;}
x=a*x_pre+b*y_pre+e;
y=c*x_pre+d*y_pre+f;
x_pre=x;
y_pre=y;
disp_x=(x+4)*639/8;
disp_y=y*47.9;
if(z==1){z=0;
putpixel(disp_x, disp_y, RED);}
else{z=1;
putpixel(disp_x, disp_y, GREEN);}
}
closegraph();
}
这是多年以前一个前辈在杂志上登的一个程序,可以在DOS TC下运行。虽然简单,但却内涵丰富。