Hello,
I’m trying to solve the test about creating a rhombus.
When I run my code the ouput seems correct but I get a error :
“Errors from testing your code: The code gave an unexpected output for input: 21”.
When the input is 21 the rhombus looks good.
Here is my code :
using System;
namespace Exam
{
class Rhombus
{
static void Main()
{
var size = int.Parse(Console.ReadLine());
int nbrEspaces = size / 2;
int nbrDieses = 1;
int i = 0;
while (i < size)
{
while (nbrDieses < size + 1)
{
for (int j = 0; j < nbrEspaces; j++)
{
Console.Write(" ");
}
for (int k = 0; k < nbrDieses; k++)
{
Console.Write("#");
}
Console.WriteLine();
i++;
nbrDieses += 2;
nbrEspaces--;
}
nbrDieses = size - 2;
while (nbrDieses >= 1 )
{
for (int j = 0; j < (size - nbrDieses ) /2 ; j++)
{
Console.Write(" ");
}
for ( int k = nbrDieses; k > 0; k--)
{
Console.Write("#");
}
Console.WriteLine();
i++;
nbrEspaces++;
nbrDieses -= 2;
}
}
}
}
}
Can anyone give me a clue ?
Thanks