Софтуерно Инженерство
Loading...
danail2003 avatar danail2003 4 Точки

Old Books от While loop

Здравейте, в Judge имам 66/100, а не мога да разбера къде ми е грешката. Ако някой ми каже ще съм му благодарен!

using System;

namespace Old_Books
{
    class Program
    {
        static void Main(string[] args)
        {
            string book = Console.ReadLine();
            int capacity = int.Parse(Console.ReadLine());

            int counter = 0;
            string searchedBook = "";

            while (searchedBook != book)
            {
                searchedBook = Console.ReadLine();

                counter++;

                if (counter >= capacity)
                {
                    Console.WriteLine("The book you search is not here!");
                    Console.WriteLine($"You checked {capacity} books.");
                    break;
                }
  
            }

            if (searchedBook == book)
            {
                Console.WriteLine($"You checked {counter-1} books and found it.");
            }
        }
    }
}

Тагове:
0
Programming Basics with C#
willystyle avatar willystyle 1590 Точки
using System;

namespace Old_Books
{
    class Program
    {
        static void Main(string[] args)
        {
            string book = Console.ReadLine();
            int capacity = int.Parse(Console.ReadLine());

            int counter = 0;
            string searchedBook = "";

            while (searchedBook != book)
            {
                searchedBook = Console.ReadLine();

                counter++;

                if (searchedBook == book)
                {
                    Console.WriteLine($"You checked {counter - 1} books and found it.");
                    break;
                }

                if (counter >= capacity)
                {
                    Console.WriteLine("The book you search is not here!");
                    Console.WriteLine($"You checked {capacity} books.");
                    break;
                }

            }
        }
    }
}

 

1
danail2003 avatar danail2003 4 Точки

Благодаря Ви !

0