A policy we have around here is to never (except perhaps under a few very special circumstances) give out solutions to problems. I'll give you a template for how your project with loops might look like along with a few MAJOR hints, but until you try the problem on your own and post the results, you'll get no further help from me. :)
1 2 3 4 5 6 7 8 9 10 11 12 13
for (/*each row of the pyramid*/)
{
for (/*some conditions based off the iteration that the loop is on*/)
{
//Print spaces.
//Hint: max_spaces = rows - 1;
}
for (/*some other conditions also based off that iteration*/)
{
//Print asterisks.
//Hint: max_asterisks = 2 * rows - 1
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace pyrmaid_print
{
class Program
{
staticvoid Main(string[] args)
{
string spaces = " ";
int perLine = 1;
int space = 0;
for (int i = 4; i > 0; i--)
{
int howMany = perLine;
Console.Write(spaces.Substring(space));
while (howMany > 0)
{
Console.Write("*");
howMany--;
}
Console.WriteLine("");
perLine += 2;
space++;
}
Console.ReadKey();
}
}
}
@hamsterman
Nothing.
I was thinking about std::bind. But it needs a constant object derived from binary_function. And AFAIK you can't bind an unary function.
It seems that boost::bind fix those issues.
We don't do it to mock the OP. It's a way to express our creativity. You should try it too.
I believe the OP was given enough help by your second post here.
It should be enough to get him started, at least.
If he posts his code asking for more help, we won't deny it.
I... really don't want to police people around. I guess I'm just passionate about seeing that this forum is a nice place for someone to come and discuss C++ or ask for help. Sorry if I come across as being "policey". It's not at all what I intended. O_o