Pietras286

Pole pewnego koła

Dec 13th, 2019
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. public class Test
  2. {
  3.     static void Main(string[] args)
  4.         {
  5.             string tekst = Console.ReadLine();
  6.             string[] tab = tekst.Split(' ');
  7.             double r = double.Parse(tab[0]);
  8.             double d = double.Parse(tab[1]);
  9.             Console.WriteLine(ObliczPole(r, d).ToString().Replace(',','.'));
  10.             Console.ReadKey();
  11.         }
  12.  
  13.         private static double ObliczPole(double r, double d)
  14.         {
  15.             double pi = 3.141592654;
  16.             double wynik = -1 * ((d / 2) * (d / 2) - r * r);
  17.             return Math.Round(pi * wynik, 2);
  18.         }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment