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 While_Old_Books
- {
- class Program
- {
- static void Main(string[] args)
- {
- string book = Console.ReadLine();
- var capacity = int.Parse(Console.ReadLine());
- int count = 0;
- string input = Console.ReadLine();
- while (capacity-- > 0)
- {
- if (book == input)
- {
- Console.WriteLine($"You checked {count} books and found it.");
- return;
- }
- count++;
- input = Console.ReadLine();
- }
- Console.WriteLine($"The book you search is not here!");
- Console.WriteLine($"You checked {count} books.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment