重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

c语言写画圆函数,c语言 画圆

c语言的画圆代码

#include graphics.h

成都创新互联主要为客户提供服务项目涵盖了网页视觉设计、VI标志设计、全网营销推广、网站程序开发、HTML5响应式网站建设移动网站建设、微商城、网站托管及成都网站维护、WEB系统开发、域名注册、国内外服务器租用、视频、平面设计、SEO优化排名。设计、前端、后端三个建站步骤的完善服务体系。一人跟踪测试的建站服务标准。已经为成都集装箱行业客户提供了网站开发服务。

#include stdio.h

#include math.h

#define TWOPI (3.1415926*2)

typedef struct point

{

int x;

int y;

}POINT;

void main()

{

int gd,gm;

POINT arr[1000];

int i;

int redius=80;

gd=DETECT;

initgraph(gd,gm,"C:\\JMSOFT\\DRV");

for(i=0;i1000;i++)

{

arr[i].x=300+redius*sin(((1.0*i)/1000)*TWOPI);

arr[i].y=300+redius*cos(((1.0*i)/1000)*TWOPI);;

}

for(i=0;i999;i++)

line(arr[i].x,arr[i].y,arr[i+1].x,arr[i+1].y);

getch();

closegraph();

}

C语言怎么画圆

#include math.h#include stdio.h#define R 10    //半径 #define X 10    //圆心x坐标 #define Y 10    //圆心Y坐标 int main(void)

{    int x,y;    int m;    int i;    for(i=Y-R;i=1;i--)

{        printf("\n");

}

for(y=R;y=-R;y--)

{

   m=2*sqrt(R*R - y*y);    //横坐标的偏移量,因为字体长宽比例为2,所以要乘2

   for(x=1;xX+R-m;x++)        //打印左半圆

   {            printf(" ");    

   }        printf("*");        for(;xX+R+m;x++)           //打印右半圆

   {            printf(" ");

   }        printf("*\n");

}

}

怎样用C语言画圆?

#include math.h

#include graphics.h /*预定义库函数*/

void circlePoint(int x,int y) /*八分法画圆程序*/

{

circle(320+x*20,240+y*20,3);

circle(320+y*20,240+x*20,3);

circle(320-y*20,240+x*20,3);

circle(320-x*20,240+y*20,3);

circle(320-x*20,240+y*20,3);

circle(320-x*20,240-y*20,3);

circle(320-y*20,240-x*20,3);

circle(320+y*20,240-x*20,3);

circle(320+x*20,240-y*20,3);

}

void MidBresenhamcircle(int r) /* 中点Bresenham算法画圆的程序 */

{

int x,y,d;

x=0;y=r;d=1-r; /* 计算初始值 */

while(xy)

{ circlePoint(x,y); /* 绘制点(x,y)及其在八分圆中的另外7个对称点 */

if(d0) d+=2*x+3; /* 根据误差项d的判断,决定非最大位移方向上是走还是不走 */

else

{ d+=2*(x-y)+5;

y--;

}

x++;

delay(900000);

} /* while */

}

main()

{

int i,j,r,graphmode,graphdriver;

detectgraph(graphdriver,graphmode);

initgraph(graphdriver,graphmode," ");

printf("中点Bresenhamcircle算法画圆的程序\n"); /*提示信息*/

printf("注意 |r|=11");

printf("\n输入半径值 r:");

scanf("%d",r);

printf("按任意键显示图形...");

getch();

cleardevice();

setbkcolor(BLACK);

for(i=20;i=620;i+=20) /*使用双循环画点函数画出表格中的纵坐标*/

for(j=20;j=460;j++)

putpixel(i,j,2);

for(j=20;j=460;j+=20) n欢迎光临学网,收藏本篇文章 [1] [2]

$False$

bsp; /*使用双循环画点函数画出表格中的横坐标*/

for(i=20;i=620;i++)

putpixel(i,j,2);

outtextxy(320,245,"0"); /*原点坐标*/

outtextxy(320-5*20,245,"-5");circle(320-5*20,240,2); /*横坐标值*/

outtextxy(320+5*20,245,"5");circle(320+5*20,240,2);

outtextxy(320-10*20,245,"-10");circle(320-10*20,240,2);

outtextxy(320+10*20,245,"10");circle(320+10*20,240,2);

outtextxy(320-15*20,245,"-15");circle(320-15*20,240,2);

outtextxy(320+15*20,245,"15");circle(320+15*20,240,2);

outtextxy(320,240-5*20,"-5");circle(320,240-5*20,2); /*纵坐标值*/

outtextxy(320,240+5*20,"5");circle(320,240+5*20,2);

outtextxy(320,240-10*20,"-10");circle(320,240-10*20,2);

outtextxy(320,240+10*20,"10");circle(320,240+10*20,2);

outtextxy(20,10,"The center of the circle is (0,0) "); /*坐标轴左上角显示提示信息*/

setcolor(RED); /*标记坐标轴*/

line(20,240,620,240); outtextxy(320+15*20,230,"X");

line(320,20,320,460); outtextxy(330,20,"Y");

setcolor(YELLOW);

MidBresenhamcircle(r);

setcolor(BLUE); /*绘制圆*/

circle(320,240,r*20);

setcolor(2);

getch();

closegraph();

}

我是c语言初学者,老师要求设计程序用函数画一个圆和一条直线。求各位路过的大神仗义相助。。

1  对于这种问题,首先分析需求,

直线:

要画直线,要的是什么,就是两个点;

所以定义一个结构体

struct point

{

int  x;

int  y;

}Ppline,Ppcircle;

画圆:

那么需要一个圆心,和一个半径;

圆心,通过上面的定义,可以获得,半径的话,直接传递参数就行了;

直线函数:

int  paintline(Ppline  startpoint,Ppline endpoint);

画圆函数:

int  paintcircle(Ppcircle   centerpoint,int  r);

用C语言写出画一个圆形的代码

可以参考下面的代码:

#includemath.h

main()

{

double y;

int x,m;

for(y=10;y=-10;y--)

{

m=2.5*sqrt(100-y*y);

for(x=1;x50-m;x++)

printf(" ");

printf("*");

for(;x50+m;x++)

printf(" ");

printf("*\n");

}

}

扩展资料:

for循表达式为:for(单次表达式;条件表达式;末尾循环体){中间循环体;}。

其中,表示式皆可以省略,但分号不可省略,因为“;”可以代表一个空语句,省略了之后语句减少,即为语句格式发生变化,则编译器不能识别而无法进行编译。for循环小括号里第一个“;”号前为一个为不参与循环的单次表达式。

参考资料来源:百度百科-for循环


当前标题:c语言写画圆函数,c语言 画圆
当前链接:http://cqcxhl.com/article/dsesehg.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP