用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - c代码库

c语言 画复杂图案

2012-11-01 作者: 程序猿style举报

[c]代码库

#include "graphics.h"
#include "math.h"
#include "dos.h"
#include "conio.h"
#include "stdlib.h"
#include "stdio.h"
#include "stdarg.h"
#define MAXPTS 15
#define PI 3.1415926
struct PTS
{
	int x,y;
};
double AspectRatio=0.85;
void LineToDemo ( void )
{
	struct viewporttype vp;
	struct PTS points[MAXPTS];
	int i, j, h, w, xcenter, ycenter;
	int radius, angle, step;
	double rads;
	printf ( " MoveTo / LineTo Demonstration" );
	getviewsettings ( &vp );
	h = vp.bottom - vp.top;
	w = vp.right - vp.left;
	xcenter = w / 2; /* Determine the center of circle */
	ycenter = h / 2;
	radius = ( h - 30 ) / ( AspectRatio * 2 );
	step = 360 / MAXPTS; /* Determine # of increments */
	angle = 0; /* Begin at zero degrees */
	for ( i=0 ; irads = ( double ) angle * PI / 180.0; /* Convert angle to radians */
	        points[i].x = xcenter + ( int ) ( cos ( rads ) * radius );
	        points[i].y = ycenter - ( int ) ( sin ( rads ) * radius * AspectRatio );
	        angle += step; /* Move to next increment */
        }
        circle ( xcenter, ycenter, radius ); /* Draw bounding circle */
for ( i=0 ; ifor ( j=i ; jmoveto ( points[i].x, points[i].y ); /* Move to beginning of cord */
                   lineto ( points[j].x, points[j].y ); /* Draw the cord */
                   }
                   }
                   }
                   main()
{
int driver,mode;
driver=CGA;
mode=CGAC0;
initgraph ( &driver,&mode,"" );
	setcolor ( 3 );
	setbkcolor ( GREEN );
	LineToDemo();
}


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...