like this:
#include <stdio.h>
char map[100][101]={0,};
void mySetPixel(int x,int y)
{
if(x<0 || y<0 || x>=100 || y>=100)return;
map[y][x]='#';
}
void drawEllipse(int x0,int y0,int a,int b )
{
if (a == 0 || b == 0) return;
int a2 = 2*a * a;
int b2 = 2*b * b;
int error = a*a*b;
int x = 0;
int y = b;
int stopy = 0;
int stopx = a2 * b ;
while (stopy <= stopx)
{
mySetPixel(x0 + x, y0 + y);
mySetPixel(x0 - x, y0 + y);
mySetPixel(x0 - x, y0 - y);
mySetPixel(x0 + x, y0 - y);
++x;
error -= b2 * (x - 1);
stopy += b2;
if (error <= 0)
{
error += a2 * (y - 1);
--y;
stopx -= a2;
}
}
error = b*b*a;
x = a;
y = 0;
stopy = b2*a;
stopx = 0;
while (stopy >= stopx)
{
mySetPixel(x0 + x, y0 + y);
mySetPixel(x0 - x, y0 + y);
mySetPixel(x0 - x, y0 - y);
mySetPixel(x0 + x, y0 - y);
++y;
error -= a2 * (y - 1);
stopx += a2;
if (error < 0)
{
error += b2 * (x - 1);
--x;
stopy -= b2;
}
}
}
int main()
{
for(int y=0;y<100;y++)
{
for(int x=0;x<100;x++)
{
map[y][x]=' ';
}
}
drawEllipse(50,50,35,15);
for(int i=0;i<100;i++)
{
printf("%s\n",map[i]);
}
return 0;
}