Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace demo
- {
- class Program
- {
- static void Main(string[] args)
- {
- //1. Четем заглавието на любимата книга
- string favouriteBook = Console.ReadLine();
- int count = 0;
- string input = Console.ReadLine();
- //2. Пуснем цикъл, който да се изпълнява дотогава, докато не прочетем заглавията на всички книги
- //=> докато не получим от конзолата "No More Books"
- while (input!= "No More Books")
- {
- // => Проверяваме дали това е любимата книга
- if(input==favouriteBook)
- {
- //=> спираме цикъла
- Console.WriteLine($"You checked {count} books and found it.");
- break;
- }
- // => ако не сме я откирли:
- // => увеличаваме брояча на заглавия, които сме прочели с 1
- count++;
- // => Четем заглавие на книга
- input = Console.ReadLine();
- }
- //3. Проверяваме дали ne сме открили книгата
- if (input != favouriteBook)
- {
- Console.WriteLine("The book you search is not here!");
- Console.WriteLine($"You checked {count} books.");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment