Dear all,
This code below draw a triangle in C
Could someone help me about drawing square,brill,rectangular
#include <stdio.h>
int main()
{
int t;
int x = 0;
int y;
t = 0;
while ( t < 7 )
{
y = 0;
while ( y < t)
{
printf("* ");
y++;
}
if(x == t)
{
printf("\n");
x = t + 1;
}
t++;
}
Hello, this is my first post, so i'll try to explain the best I can.
Drawing a circle (without using a graphic library, and by using "*") can be thought as drawing a circle on a math paper. You take your center point, and a radius. Then go through all the points forming the square containing the desired circle, and set a condition to be followed so that the point can be on the circle. Ideally, the condition should be the algebraic definition of the circle: square(x)+square(y)=square(r). But, then again, we're in a finite space, with integer coordinates, thus making following that rule a bit harder. So, instead of equality, we'll use inequalities. I've also fine tuned the points resulted, giving it a more "round" look. Here's the code I've written, and the output for a C(10, 10, 8):