September 5, 2011

Example 9

Task:
Create a program that ask for input integers n with the following provisions:
if  n = 5


Output : 
*       *
  *   *
    *
  *   *
*       *
 Code:
for row <-- 1 to N do
{
  for column <-- 1 to N do
  {
    if (row = column) or (row + column = N + 1) then
    {
      output("*");
    } else {
      output(" ");
    }
    output("\n"); /* new line */
  }
}



No comments:

Post a Comment