c语言经典算法100例.rar

源代码在线查看: 10-3.c

软件大小: 243 K
上传用户: xmmgood
关键词: 100 c语言 算法
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*10-3.c*/
				#include 
				#include 
				#include 
				#include 
				#include 
				int color=4,i;
				int start_x,end_x,start_y,end_y;
				int X[480],Y[640];
				void hor_wave_line(int x0,int y1,int x1,int a,int k);
				void ver_wave_line(int x0,int y0,int y1,int a,int k);
				main( )
				{
				  int driver=EGA,mode=EGAHI;
				  initgraph(&driver,&mode,"");
				  cleardevice();
				  start_x=200;
				  start_y=50;
				  end_x=450;
				  end_y=200;
				  setcolor(4);
				hor_wave_line(start_x,start_y,end_x,0,2);
				ver_wave_line(end_x,start_y,end_y,10,3);
				hor_wave_line(start_x,end_y,end_x,0,2);
				line(start_x,start_y-2,start_x,end_y+5);
				setfillstyle(1,14);
				bar3d(start_x,start_y-5,start_x,end_y+150,2,1);
				setfillstyle(1,4);
				floodfill(start_x+50,start_y+50,4);
				setactivepage(1);
				hor_wave_line(start_x,start_y,end_x,0,4);
				ver_wave_line(end_x,start_y,end_y,10,6);
				hor_wave_line(start_x,end_y,end_x,0,4);
				line(start_x,start_y-2,start_x,end_y+5);
				setfillstyle(1,14);
				bar3d(start_x,start_y-5,start_x,end_y+150,2,1);
				setfillstyle(1,4);
				floodfill(start_x+50,start_y+50,4);
				while(! kbhit( )){
				setvisualpage(1);
				delay(200);
				setvisualpage(0);
				delay(200);
				}
				closegraph( );
				}
				void hor_wave_line(int x0,int y0,int x1,int a,int k)
				{
				float rad=3.1415926/180.0;
				for(i=0;i				   Y[i]=random(1)+(int)(5*sin((i*k+a)*rad));
				for(i=x0;i				{
				  moveto(i,Y[i]+y0);
				  lineto(i,Y[i]+y0);
				}
				lineto(x1,y0);
				}
				void ver_wave_line(int x0,int y0,int y1,int a,int k)
				{
				float rad=3.1415926/180.0;
				randomize( );
				for(i=0;i				   X[i]=random(1)+(int)(5*sin((i*k+a)*rad));
				for(i=y0+1;i				{
				  lineto(X[i]+x0,i);
				  moveto(X[i]+x0,i);
				}
				lineto(x0,y1);
				}
							

相关资源