IordanRujinov

RectangleArea

Oct 4th, 2018
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 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 ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // 2D rectangle area; правоъгълна площ
  14.             double x1 = double.Parse(Console.ReadLine());
  15.             double y1 = double.Parse(Console.ReadLine());
  16.             double x2 = double.Parse(Console.ReadLine());
  17.             double y2 = double.Parse(Console.ReadLine());
  18.  
  19.             double LongSide = Math.Abs(x1 - x2); // a
  20.             double ShortSide =  Math.Abs(y1 - y2); // b
  21.  
  22.             double S = LongSide * ShortSide;
  23.             double P = 2 * LongSide + 2 * ShortSide;
  24.  
  25.             Console.WriteLine(S);
  26.             Console.WriteLine(P);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment