Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. public class Program{
  2.  
  3. public static uint CheckInterval(uint value, uint min, uint max){ // ограничить число диапазоном
  4. return (value < min) ? min : (value > max) ? max : value;
  5. }
  6.  
  7. public static void Main() {
  8.  
  9. Console.Write("Год:");
  10. uint y = uint.Parse(Console.ReadLine());
  11.  
  12. Console.Write("Месяц:");
  13. uint m = uint.Parse(Console.ReadLine());
  14.  
  15. Console.Write("День:");
  16. uint d = uint.Parse(Console.ReadLine());
  17.  
  18. y = CheckInterval(y, 1, 2100);
  19. m = CheckInterval(m, 1, 12);
  20. d = CheckInterval(d, 1, 31);
  21.  
  22. uint time = 0 | y << 16 | m << 8 | d;
  23.  
  24. Console.WriteLine(Convert.ToString(time, 2));
  25. Console.WriteLine(y.ToString() +":" + m.ToString() +":" + d.ToString() );
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement