Aug 3, 2013 at 10:16am
Hi, how can i write a program that prints out this..
*****
****
***
**
*
with the user inputting the top number to start off from.
Thanks
Aug 3, 2013 at 5:28pm
Another:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
#include <iomanip>
void print_stars( const unsigned int amount )
{
if ( amount == 0 ) return;
std::cout << std::setfill('*') << std::setw( amount + 1 ) << '\n';
print_stars( amount - 1 );
}
int main(void)
{
print_stars(10);
return 0;
}
|
Last edited on Aug 3, 2013 at 5:29pm