I want to turn this...
**********
*********
********
*******
******
*****
****
***
**
*
into this...
**********
!*********
!!********
!!!*******
!!!!******
!!!!!*****
!!!!!!****
!!!!!!!***
!!!!!!!!**
!!!!!!!!!*
without using field with specifiers. I can only use for loops and one printf for asterisks (*) and one printf for space ( ). Here's my code. Thanks.
Code:
#include %26lt;stdio.h%26gt;
int main() {
int f, g;
for(f = 0; f %26lt; 10; f++)
{
for(g = f; g %26lt; 10; g++)
{
printf("*");
}
printf("\n");
}
return 0;
}
I was able to right justify this...
*
**
***
****
*****
******
*******
********
*********
**********
using this code...
while(h %26gt;= 0)
{
for(j = 0; j %26lt; h; j++)
{
printf(" ");
}
--h;
for(j = 0; j %26lt; i; j++)
{
printf("*");
}
++i;
printf("\n");
}
How do I right justify this asterisk pattern (C)?
Hmmm. So using printf() field modifiers are out, eh? Well, this becomes more math-ish, then.
int h=10, i=0;
while(h %26gt;= 0)
{
for(j = 0; j %26lt; i; j++)
printf(" ");
for(j = 0; j %26lt; h; j++)
printf("*");
i++;
h--;
printf("\n");
}
Reply:welcome. thanks for coming back and choosing an answer! Report It
Reply:google is your friend: http://www.space.unibe.ch/comp_doc/c_man...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment