Advertisement
Svetli0o

PeaceOfCake

Apr 3rd, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class Program
  8. {
  9.     static void Main(string[] args)
  10.     {
  11.         ulong a = ulong.Parse(Console.ReadLine());
  12.         ulong b = ulong.Parse(Console.ReadLine());
  13.         ulong c = ulong.Parse(Console.ReadLine());
  14.         ulong d = ulong.Parse(Console.ReadLine());
  15.         ulong denominator = b * d;
  16.         a *= d;
  17.         c *= b;
  18.         ulong sum = a + c;
  19.         decimal asd = (a + c) / denominator;
  20.         if (asd >= 1)
  21.         {
  22.             ulong num = (a + c) / denominator;
  23.             Console.WriteLine(num);
  24.             Console.WriteLine("{0}/{1}", sum, denominator);
  25.         }
  26.         else
  27.         {
  28.             decimal num = (Convert.ToDecimal(a) + Convert.ToDecimal(c)) / Convert.ToDecimal(denominator);
  29.             Console.WriteLine("{0:0.0000000000000000000000}", num);
  30.             Console.WriteLine("{0}/{1}", sum, denominator);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement