Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class PeaceOfCake
- {
- static void Main()
- {
- decimal a = decimal.Parse(Console.ReadLine());
- decimal b = decimal.Parse(Console.ReadLine());
- decimal c = decimal.Parse(Console.ReadLine());
- decimal d = decimal.Parse(Console.ReadLine());
- decimal result = a / b + c / d;
- decimal denominator = b * d;
- a *= (denominator / b);
- c *= (denominator / d);
- if (result >= 1)
- {
- Console.WriteLine(Math.Floor(result));
- }
- else
- Console.WriteLine("{0:F22}", result);
- Console.WriteLine("{0}/{1}", a + c, denominator);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement