Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class NumbersDivisibleByFive
- {
- static void Main()
- {
- int numberA, numberB, count;
- string input;
- // изисква въвеждане на долна и горна граница на диапазона
- do
- {
- Console.Write("Въведете число А: ");
- input = Console.ReadLine();
- }
- while (!(int.TryParse(input, out numberA) && (numberA > 0)));
- do
- {
- Console.Write("Въведете число B: ");
- input = Console.ReadLine();
- }
- while (!(int.TryParse(input, out numberB) && (numberB > 0)));
- // следва самото пресмятане
- count = (Math.Max(numberA, numberB) / 5) - ((Math.Min(numberA, numberB) - 1) / 5);
- Console.WriteLine("Броят на числата в диапазона ({0} .. {1}), които се делят на 5 е {2}. \n", Math.Min(numberA, numberB), Math.Max(numberA, numberB), count);
- }
- }
Add Comment
Please, Sign In to add comment