#include <stdio.h>
#include <conio.h>
#include<math.h>
main()
{
int r,q,w,color
int gdriver=DETECT,gmode/*设置图形驱动*/
int Bresenham_Ciecle()/*定义子函数*/
printf("please input the centre of a circle x0,y0\n")
scanf("%d,%d",&q,&w)
if(q>=320||q<=-320||w<=-250||w>=250)
{printf("please input the centre of a circle again x0,y0\n")
scanf("%d,%d",&q,&w)} /*输入圆心位置越界输出信息*/
printf("please input the numble of radius r=")
scanf("%d",&r)
if(r<=0||r>=500)
{
printf("r is error,r>0,please input the numble of r=")
scanf("%d",&r)
}/*输入半径*/
printf("please input the numble of color=")
scanf("%d",&color)
initgraph(&gdriver,&gmode,"D:\\TC")
setcolor(color)/*设置图形颜色*/
Bresenham_Ciecle(q,w,r,color)/*绘图*/
getch()
}
Bresenham_Ciecle(int q,int w,int r,int color)
{
int x,y,t,v,delta,delta1,delta2,direction
char buffera[20]
char bufferb[20]
t=getmaxx()/2
v=getmaxy()/2/*选定圆心*/
sprintf(buffera, "(%d,%d)", q,w)/*打印圆心坐标*/
sprintf(bufferb, "(0,0) R=%d",r)/*打印原点坐标及半径*/
moveto(t,v+4)
outtext(bufferb)/*圆点坐标定位输出*/
q=q+tw=v-w
moveto(q,w)
outtext(buffera)/*原点坐标定位输出*/
line(1,v,2*t,v)
line(t,2*v,t,1)/*画坐标*/
x=qy=r+w
line(q, w, x, y)/*画半径*/
delta=2*(1-r)
while(y-w>=0)
{
putpixel(x,y,color)/*右下方1/4个圆*/
putpixel(2*q-x,y,color)/*右上方1/4个圆(从右下方1/4个圆对称复制)*/
putpixel(x,2*w-y,color)/*左下方1/4个圆(从右下方1/4个圆对称复制)*/
putpixel(2*q-x,2*w-y,color)/*左上方1/4个圆(从右下方1/4个圆对称复制)*/
if(delta<0)
{
delta1=2*(delta+y-w)-1
if(delta1<=0) direction=1
else direction=2
}
else if(delta>0)
{
delta2=2*(delta-x+q)-1
if(delta2<=0) direction=2
else direction=3
}
else
direction=2
switch(direction)
{
case 1: x++
delta+=2*(x-q)+1
break
case 2: x++
y--
delta+=2*(1+x-y-q+w)
break
case 3: y--
delta+=-2*(y-w)+1
break
}
}
}
void far bar3d(int x1, int y1, int x2, int y2,int depth,int topflag)当topflag为非0时, 画出一个三维的长方体。当topflag为0时,三维图形不封顶,
实际上很少这样使用。
void far setfillstyle(int pattern, int color)color的值是当前屏幕图形
模式时颜色的有效值,SOLID_FILL 1 以实填充
void far floodfill(int x, int y, int border)
其中:x, y为封闭图形内的任意一border为边界的颜色,也就是封闭图形轮廓的
颜色。调用了该函数后,将用规定的颜色和图模填满整个封闭图形。
#include<stdlib.h>
#include<graphics.h>
main()
{
int gdriver, gmode
struct fillsettingstype save
gdriver=DETECT
initgraph(&gdriver, &gmode, "")
setbkcolor(BLUE)
cleardevice()
setcolor(LIGHTRED)
setlinestyle(0,0,3)
setfillstyle(1,14)/*设置填充方式*/
bar3d(100,200,400,350,200,1)/*画长方体并填充*/
floodfill(450,300,LIGHTRED)
/*填充长方体另外两个面*/
floodfill(250,150, LIGHTRED)
getch()
closegraph()
}
如果你会编程序而不会画流程图,建议你应该先把自己的程序研究一遍。若是画主程序流程图,那就需看懂主函数的程序,按照main()函数中的具体书写过程来画,例如:程序开始---定义变量---初始化变量---使用选择或者循环或者顺序结构---调用某一个子函数(可以没有)---程序结束以上是最简单的程序流程图画法。若你是画某一算法或是某一模块的流程图,就要把相应的算法或是模块看懂。分析算法或是模块的具体走法,根据此走法就可以画出对应的流程图。如果你是初学者,想根据流程图的画法而去尝试编程,建议你就一定要研究清楚每一个使用到的算法,读懂题目再开始编程。下面是使VISO画流程图的几个要点:1、选择下载一个合适版本的VISO2、程序开始结束用胶囊3、分页用圆圈4、输入用平行四边形5、语句用方块6、判断用菱形7、打印用波浪