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

Q: Arrow - Drawing C# Task

+8 votes

SoftUni has opened a new training center in Kaspichan, but the people there did not know how to find it. Your task is to print a vertical arrow, which will be used to indicate the path to the new building in the city. This will help thousands of people to become software engineers. Please help them!

Input

The input data should be read from the console.

  • On the only line will hold and integer number N (always odd number), indicating the width of the arrow.

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

Output

The output should be printed on the console. Use the “#” (number sign) to mark the arrow and “.” (dot) for the rest. Follow the examples below.

Constraints

  • N will always be a positive odd number between 3 and 79 inclusive.
  • Allowed working time for your program: 0.1 seconds.
  • Allowed memory: 16 MB.

Examples

arrow drawing c# task example 1

arrow drawing c# task example 2

arrow drawing c# task example 3

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

1 Answer

+1 vote
 
Best answer

Here's my drawing solution, dude:

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

class Arrow
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        Console.WriteLine("{0}{1}{0}",
            new string('.', ((n * 2 - 1) - n) / 2),
            new string('#', n));//1ST PART - STATIC


        for (int i = 0; i < n - 2; i++)//2ND PART
        {
            Console.WriteLine("{0}{1}{2}{1}{0}",
                new string('.', n / 2),
                new string('#', 1),
                new string('.', n - 2));
        }

        Console.WriteLine("{0}{1}{0}",
            new string('#', n / 2 + 1),
            new string('.', ((n * 2 - 1) - 2 * (n / 2 + 1))));//3RD PART - STATIC

        for (int i = 0; i < n - 2; i++)//4TH PART
        {
            Console.WriteLine("{0}{1}{2}{1}{0}",
                new string('.', i + 1),
                new string('#', 1),
                new string('.', ((n * 2 - 1) - 4 - (i*2))));
        }
        Console.WriteLine("{0}{1}{0}",
            new string('.',n-1),
            new string('#', 1));//5TH PART - STATIC
    }
}

 

answered by user andrew
selected by user golearnweb
...