Advertisement
ivan_yosifov

Piece_Of_Cake

Dec 8th, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2.  
  3. class PieceOfCake
  4. {
  5.     static void Main()
  6.     {
  7.         long A = long.Parse(Console.ReadLine());
  8.         long B = long.Parse(Console.ReadLine());
  9.         long C = long.Parse(Console.ReadLine());
  10.         long D = long.Parse(Console.ReadLine());
  11.  
  12.         long nominator = (A * D) + (B * C);
  13.         long denominator = (B * D);
  14.  
  15.         decimal division = (decimal)nominator / denominator;
  16.  
  17.         if (division >= 1)
  18.         {
  19.             Console.WriteLine("{0}", (long)division);
  20.         }
  21.         else
  22.         {
  23.             Console.WriteLine("{0:F22}", division);
  24.         }
  25.         Console.WriteLine("{0}/{1}", nominator, denominator);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement