Okay, so i just started programming a week ago and i know some stuff but am completely stumped with this.
I can print out this pattern easy, where "-" = spaces
*******
-******
--*****
---****
----***
---****
--*****
-******
*******
by doing
Code:
for(r=0;r<9;r++)
{
if(r<5)
{
m=1;
b=0;
m1=-1;
b1=7;
}
else
{
m=-1;
b=8;
m1=1;
b1=-1;
}
for(s=0;s<(m*r)+b;s++)
printf(" ");
for(c=0;c<(m1*r)+(b1);c++)
printf("*");
printf("\n");
}
but i cannot seem to do,
************************* 25
**************** 16
********* 9
**** 4
* 1
Code:
for(r=0;r<5;r++)
{
for(c=0;c<(r^2)+(-10*r)+25;c++)
printf("*");
printf("\n");
}
i tried using a quadratic formula to find the slope instead of y=mx+b. but it didnt print out right. Any help would be kind.