Venciity

[C#] Домашно Console Input/Output - задача 4

Feb 1st, 2014
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2.  
  3. class NumbersDivisibleByFive
  4. {
  5.     static void Main()
  6.     {
  7.         int numberA, numberB, count;
  8.         string input;
  9.  
  10.         // изисква въвеждане на долна и горна граница на диапазона
  11.         do
  12.         {
  13.             Console.Write("Въведете число А: ");
  14.             input = Console.ReadLine();
  15.         }
  16.         while (!(int.TryParse(input, out numberA) && (numberA > 0)));
  17.  
  18.         do
  19.         {
  20.             Console.Write("Въведете число B: ");
  21.             input = Console.ReadLine();
  22.         }
  23.         while (!(int.TryParse(input, out numberB) && (numberB > 0)));
  24.  
  25.         // следва самото пресмятане
  26.         count = (Math.Max(numberA, numberB) / 5) - ((Math.Min(numberA, numberB) - 1) / 5);
  27.         Console.WriteLine("Броят на числата в диапазона ({0} .. {1}), които се делят на 5 е {2}. \n", Math.Min(numberA, numberB), Math.Max(numberA, numberB), count);
  28.     }
  29. }
Add Comment
Please, Sign In to add comment