anizko

05. Left and Right Sum

Apr 10th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Left_and_Right_Sum
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             double firstSum = 0;
  11.             double secountSum = 0;
  12.             double num = 0;
  13.  
  14.             for (int i=1;i<=n;i++)
  15.             {
  16.              
  17.                 firstSum += double.Parse(Console.ReadLine());
  18.             }
  19.             for (int i = 1; i <= n; i++)
  20.             {
  21.              
  22.                 secountSum += double.Parse(Console.ReadLine());
  23.             }
  24.  
  25.  
  26.             if (firstSum == secountSum)
  27.             {
  28.                 Console.WriteLine($"Yes, sum = {secountSum}");
  29.             }
  30.             else
  31.             {
  32.                 Console.WriteLine($"No, diff = {Math.Abs(firstSum - secountSum)}");
  33.             }
  34.  
  35.            
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment