By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy

Q: King of Thieves (C# Drawing Task)

+3 votes

Once upon a time there was a kingdom and everyone in the kingdom was a thief. Izzy wanted to become the King of Thieves and so started stealing only perfect gems from other thieves. Help Izzy by showing him what a perfect gem with given parameters should look like.


The input data should be read from the console.

  • The first line will hold the size of the gem – n.
  • The second line will hold the type of the gem – a symbol: e.g. ‘*’.

The input data will always be valid and in the format described. There is no need to check it explicitly.


The output should be printed on the console. It should consist of ‘n’ lines, holding the gem.


  • The number n will be a positive odd integer between 3 and 59, inclusive.
  • The type of the gem will be a symbol from the standard ASCII table.
  • Allowed working time for your program: 0.1 seconds.
  • Allowed memory: 16 MB.


drawing task in c sharp example 1

drawing task in c sharp example 2

drawing task in c sharp example 3


asked in C# category by user nikole
edited by user golearnweb

1 Answer

+2 votes
Best answer

These drwing C# tasks are very amusing :-) Really enjoy solving them!

Here's my solution for tis one:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class KingOfThieves
    static void Main()
        int n = int.Parse(Console.ReadLine());
        char symbol = char.Parse(Console.ReadLine());

        for (int i = 0; i < n / 2; i++)
                new string(('-'), n / 2 - i),
                new string((symbol), 1 + 2 * i));

                new string((symbol), n));

        for (int i = 0; i < n / 2; i++)
                new string(('-'), 1 + i),
                new string((symbol), n - ((1 + i) * 2)));

BTW - the middle line is static - in the yellow color:

explanation of the task

answered by user ak47seo
edited by user golearnweb
Good job! thanks ak47seo!