Advertisement
Guest User

HalfSum

a guest
Jul 19th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2. class HalfSum
  3. {
  4.     static void Main()
  5.     {
  6.         int nums = int.Parse(Console.ReadLine());
  7.         int sumLeft = 0;
  8.         int sumRight = 0;
  9.         for (int i = 0; i < nums; i++)
  10.         {
  11.             sumLeft += int.Parse(Console.ReadLine());
  12.         }
  13.         for (int i = nums; i < nums * 2; i++)
  14.         {
  15.             sumRight += int.Parse(Console.ReadLine());
  16.         }
  17.         if (sumLeft == sumRight)
  18.         {
  19.             Console.WriteLine("Yes, sum={0}", sumLeft);
  20.         }
  21.         else
  22.         {
  23.             int diff = Math.Abs(sumLeft - sumRight);
  24.             Console.WriteLine("No, diff={0}", diff);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement