Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

ValenNEW avatar ValenNEW 51 Точки

C# Programming Basics Online Exam - 14 and 15 April 2018 - PIN

Здравейте!

Моля за съдействие. Решавам тук една задача - https://judge.softuni.bg/Contests/Practice/Index/978#13 .

Zero тестовете ми са ок. А всички останали се провалят.

Гледах, гледах. Не мога да открия, къде е евентуално грешката.

Прилагам и сорса. При мен се компилира ок. И изглежда ок. Измерил съм и колоните и редовете. Верни са.

 

Поздрави и благодаря предварително!

 

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

class DrawTheWordPin
{
    static void Main(string[] args)
    {
        int userInput = int.Parse(Console.ReadLine());
        int imageWidth = 6 * userInput + 10;
        if (userInput >= 2 &&
            userInput <=20)
        {
            DrawTopLine(userInput, imageWidth);
            DrawUpperLines(userInput, imageWidth);
            DrawMiddleLine(userInput, imageWidth);
            DrawLowerLines(userInput, imageWidth);
            DrawBottomLine(userInput, imageWidth);
        }
        else
        {
            Console.WriteLine("Enter correct number between 2 and 20");
        }
    }
    private static void DrawTopLine(int userInput, int imageWidth)
    {
        Console.Write("/`");
        for (int i = 0; i < userInput * 2; i++)
        {
            Console.Write("P");
        }
        for (int i = 0; i < userInput; i++)
        {
            Console.Write(" ");
        }
        Console.Write("/`I");
        for (int i = 0; i < userInput; i++)
        {
            Console.Write(" ");
        }
        Console.Write("/`N");
        for (int i = 0; i <= userInput * 2; i++)
        {
            Console.Write(" ");
        }
        Console.Write("N\n");
    }
    private static void DrawUpperLines(int userInput, int imageWidth)
    {
        for (int a = 0; a < userInput - 1; a++)
        {
            Console.Write("| P");
            for (int b = 0; b < userInput * 2 - 2; b++)
            {
                Console.Write(" ");
            }
            Console.Write("P");
            for (int i = 0; i < userInput; i++)
            {
                Console.Write(" ");
            }
            Console.Write("| I");
            for (int i = 0; i < userInput; i++)
            {
                Console.Write(" ");
            }
            Console.Write("| N");
            for (int i = 0; i < a; i++)
            {
                Console.Write(" ");
            }
            Console.Write("N");
            for (int i = 0; i <= userInput * 2 - 1 - a; i++)
            {
                Console.Write(" ");
            }
            Console.Write("N\n");
        }
    }
    private static void DrawMiddleLine(int userInput, int imageWidth)
    {
        Console.Write("| ");
        for (int i = 0; i < userInput * 2; i++)
        {
            Console.Write("P");
        }
        for (int i = 0; i < userInput; i++)
        {
            Console.Write(" ");
        }
        Console.Write("| I");
        for (int i = 0; i < userInput; i++)
        {
            Console.Write(" ");
        }
        Console.Write("| N");
        for (int i = 0; i < userInput - 1; i++)
        {
            Console.Write(" ");
        }
        Console.Write("N");
        for (int i = 0; i <= userInput * 2 - userInput; i++)
        {
            Console.Write(" ");
        }
        Console.Write("N\n");
    }
    private static void DrawLowerLines(int userInput, int imageWidth)
    {
        for (int a = 0; a < userInput; a++)
        {
            Console.Write("| P");
            if (userInput > 2)
            {
                Console.Write("P");
            }
            else
            {
                Console.Write(" ");
            }
            for (int b = 0; b < userInput * 2 - 2; b++)
            {
                Console.Write(" ");
            }
            for (int i = 0; i < userInput; i++)
            {
                Console.Write(" ");
            }
            Console.Write("| I");
            for (int i = 0; i < userInput; i++)
            {
                Console.Write(" ");
            }
            Console.Write("| N");
            for (int i = 0; i < userInput + a; i++)
            {
                Console.Write(" ");
            }
            Console.Write("N");
            for (int i = 0; i < userInput * 2 - userInput - a; i++)
            {
                Console.Write(" ");
            }
            Console.Write("N\n");
        }
    }
    private static void DrawBottomLine(int userInput, int imageWidth)
    {
        Console.Write("\\_P");
        if (userInput > 2)
        {
            Console.Write("P");
        }
        else
        {
            Console.Write(" ");
        }
        for (int b = 0; b < userInput * 2 - 2; b++)
        {
            Console.Write(" ");
        }
        for (int i = 0; i < userInput; i++)
        {
            Console.Write(" ");
        }
        Console.Write("\\_I");
        for (int i = 0; i < userInput; i++)
        {
            Console.Write(" ");
        }
        Console.Write("\\_N");
        for (int i = 0; i <= userInput; i++)
        {
            Console.Write(" ");
        }
        Console.Write(" ");
        for (int i = 0; i < userInput * 2 - userInput - 2; i++)
        {
            Console.Write(" ");
        }
        Console.Write("NN\n");
    }
}

 

-1
Programming Basics
gudiominator avatar gudiominator 1 Точки

Ето и едно решение й от ме с new string. Дано бъде полезно на някой. https://pastebin.com/SjeHVw4P

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.