I deduce a rhombus in the console in this way:

class Program { static void Main(string[] args) { int x = 6; int y = 6; int x1 = 6; int y1 = 6; int size = 6; for (int i = 0; i < size; i++) { Console.SetCursorPosition(x, y + i); Console.WriteLine("*"); Console.SetCursorPosition(x - i, y + size); Console.WriteLine("*"); Console.SetCursorPosition(x - i, y + i); Console.WriteLine("*"); Console.SetCursorPosition(x, y + i); Console.WriteLine("*"); Console.SetCursorPosition(x + i, y + size); Console.WriteLine("*"); Console.SetCursorPosition(x + i, y + i); Console.WriteLine("*"); } for (int i = 0; i < size; i++) { Console.SetCursorPosition(x1, y1 + i); Console.WriteLine("*"); Console.SetCursorPosition(x1 + i, y1 - size); Console.WriteLine("*"); Console.SetCursorPosition(x1 + i, y1 - i); Console.WriteLine("*"); Console.SetCursorPosition(x1, y1 + i); Console.WriteLine("*"); Console.SetCursorPosition(x1 - i, y1 - size); Console.WriteLine("*"); Console.SetCursorPosition(x1 - i, y - i); Console.WriteLine("*"); } Console.ReadKey(); } } 

But it turns out not a rhombus, but something like this:

  * * * * * * * * * * * * * * * * 

And it should be:

 > * > * * > * * * * * > * * > * 
  • Note that you have the same lower triangle as the upper one for the expected result: try to just swap cycles - Grundy
  • @Grundy, nothing has changed - Julia Ponomareva
  • it cannot be, your positions are calculated in different ways - Grundy
  • You can try and make sure - Julia Ponomareva

1 answer 1

Almost.

You must always remember that your y coordinate in the console is counted down, not up. Because of this confusion.

You have (x, y) - the upper reference point, so you need

 int y = 0; 

Similarly, (x1, y1) is the lower reference point, therefore

 int y = 12; 

Well, a few minor typos: in the second loop, you have Console.SetCursorPosition(x1, y1 + i); but since you are counting up from the lower reference point, then you need a minus. (In two places.) And yet in the same cycle, you mistakenly use y instead of y1 once.

With the corrected errors, I got this:

  * *** * * * * * * * * * * * * *********** * * * * * * * * * * * * *** * 
  • These are words that seem familiar, but I don’t understand what is written :-D - Grundy
  • @Grundy: Is that even? :) - VladD
  • Aha :-) did not delve into the code - but by explanation, it is clear that something in the code :) - Grundy
  • @Grundy, but do not tell me how to fix the position of the figures (the triangle and the square move along the console, when their coordinates match, you need to fix their position) - Julia Ponomareva