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