#include<iostream>
#include<graphics.h>
#include<conio.h>
using namespace std;

void MidPoint_Circle(const int& x0, const int& y0, const int& r)
{
	initgraph(800, 640);
	int d = 1 - r, x = 0, y = r;
	while (x <= y)
	{
		cout << "x=" << x << ",y=" << y << ",d=" << d << endl;
		putpixel(x + x0, y + y0,RED);
		putpixel(x + x0, -y + y0,RED);
		putpixel(-x + x0, y + y0, RED);
		putpixel(-x + x0, -y + y0, RED);
		putpixel(y + x0, x + y0, RED);
		putpixel(y + x0, -x + y0, RED);
		putpixel(-y + x0, x + y0, RED);
		putpixel(-y + x0, -x + y0, RED);
		if (d < 0)
		{
			d += (2 * x + 3);
			x++;
		}
		else
		{
			d += (2 * x - 2 * y + 5);
			x++;
			y--;
		}
	}
	_getch();
	closegraph();
}

int main(void)
{
	MidPoint_Circle(200,200,10);
	return 0;
}
Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐