Advertisement
Guest User

Untitled

a guest
Apr 11th, 2014
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. using System;
  2.  
  3. class PeaceOfCake
  4. {
  5. static void Main()
  6. {
  7. decimal a = decimal.Parse(Console.ReadLine());
  8. decimal b = decimal.Parse(Console.ReadLine());
  9. decimal c = decimal.Parse(Console.ReadLine());
  10. decimal d = decimal.Parse(Console.ReadLine());
  11.  
  12. decimal result = a / b + c / d;
  13.  
  14. decimal denominator = b * d;
  15.  
  16. a *= (denominator / b);
  17. c *= (denominator / d);
  18.  
  19. if (result >= 1)
  20. {
  21. Console.WriteLine(Math.Floor(result));
  22. }
  23. else
  24. Console.WriteLine("{0:F22}", result);
  25.  
  26. Console.WriteLine("{0}/{1}", a + c, denominator);
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement