Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace While_Loop___Exercise
- {
- class Program
- {
- static void Main(string[] args)
- {
- string NameBook = Console.ReadLine();
- int CountBook = int.Parse(Console.ReadLine());
- int Counter = 0;
- string SearchBook = Console.ReadLine();
- while (NameBook!=SearchBook)
- {
- if (Counter < CountBook)
- {
- SearchBook = Console.ReadLine();
- }
- else if (Counter >= CountBook)
- {
- Console.WriteLine("The book you search is not here!");
- Console.WriteLine($"You checked {Counter} books.");
- break;
- }
- ++Counter;
- }
- if (NameBook == SearchBook)
- {
- Console.WriteLine($"You checked {Counter} books and found it.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment