Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace FavoriteBook
- {
- class Program
- {
- static void Main(string[] args)
- {
- string favouriteBook = Console.ReadLine();
- int numberOfBooks = int.Parse(Console.ReadLine());
- int counter = 0;
- bool bookIsFound = false;
- string nextBookName = Console.ReadLine();
- while (counter < numberOfBooks)
- {
- nextBookName = Console.ReadLine();
- }
- while (counter < numberOfBooks)
- {
- if (nextBookName == favouriteBook)
- {
- bookIsFound = true;
- break;
- }
- else if (nextBookName != favouriteBook)
- counter++;
- nextBookName = Console.ReadLine();
- }
- if (bookIsFound == false)
- {
- Console.WriteLine("The book you search is not here!");
- Console.WriteLine($"You checked{numberOfBooks} books.");
- }
- else
- {
- Console.WriteLine($"You checked{counter} books and found it.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement