请给出代码,和运行结果图,感谢

用中点法实现圆的绘制。圆的半径取200~800之间的一个随机数

用Qt运行

#include <graphics.h>
#include <conio.h>
#include<stdio.h>
#include <cstdlib> 
// 中点画圆法
void Circle_Midpoint(int x, int y, int r, int color)
{
	int tx = 0, ty = r, d = 1 - r;
 
	while(tx <= ty)
	{
		// 利用圆的八分对称性画点
		putpixel(x + tx, y + ty, color);
		putpixel(x + tx, y - ty, color);
		putpixel(x - tx, y + ty, color);
		putpixel(x - tx, y - ty, color);
		putpixel(x + ty, y + tx, color);
		putpixel(x + ty, y - tx, color);
		putpixel(x - ty, y + tx, color);
		putpixel(x - ty, y - tx, color);
 
		if(d < 0)
			d += 2 * tx + 3;
		else
			d += 2 * (tx - ty) + 5, ty--;
 
		tx++;
	}
}
 
 
// 主函数
void main()
{
 
	int x=200,y=400,r;
	r=rand()%600+200;
	initgraph(640, 480);
	
	// 测试画圆
	Circle_Midpoint((x,y,r, RED);
	
	// 按任意键退出
	getch();
	closegraph();
}

如有帮助望采纳。点击我回答右上角【采纳】按钮。

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps: 问答会员年卡【8折】购 ,限时加赠IT实体书,即可 享受50次 有问必答服务,了解详情>>>https://t.csdnimg.cn/RW5m