Advertisement
martyz

RainDrops

Dec 10th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 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. namespace Raindrops
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double region = double.Parse(Console.ReadLine());
  14.             decimal density = decimal.Parse(Console.ReadLine());
  15.             decimal result = 0;
  16.  
  17.  
  18.             for (int i = 0; i < region; i++)
  19.             {
  20.                 double[] input = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
  21.                 double raindropsCount = input[0];
  22.                 double squareMeters = input[1];
  23.                 //Console.WriteLine(raindropsCount / squareMeters);
  24.                 result += (decimal)(raindropsCount / squareMeters);
  25.  
  26.             }
  27.  
  28.             try
  29.             {
  30.                 Console.WriteLine("{0:F3}", result / density);
  31.             }
  32.             catch (Exception e)
  33.             {
  34.  
  35.                 Console.WriteLine("{0:F3}", result);
  36.             }
  37.  
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement