desislava_topuzakova

5. Невалидно число - начин 3

Nov 21st, 2021
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05._Invalid_Number
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int number = int.Parse(Console.ReadLine());
  10. //валидно: [100…200] или е 0 -> print
  11. //невалидно -> print invalid
  12. bool isValid = (number >= 100 && number <= 200) || number == 0;
  13. //isValid = true -> числото е валидно -> print nothing
  14. //isValid = false -> числото не е валидно -> print invalid
  15.  
  16. if (!isValid)
  17. {
  18. Console.WriteLine("invalid");
  19. }
  20. }
  21. }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment