nikolayneykov

Untitled

Oct 18th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 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 Ex._6
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int sumLeft = 0;
  15.             int sumRight = 0;
  16.  
  17.             for (int i = 0; i < 2 * n; i++)
  18.             {
  19.                 if (i < n)
  20.                 {
  21.                     sumLeft += int.Parse(Console.ReadLine());
  22.                 }
  23.                 else
  24.                 {
  25.                     sumRight += int.Parse(Console.ReadLine());
  26.                 }
  27.             }
  28.  
  29.  
  30.             if (sumLeft == sumRight)
  31.  
  32.             { Console.WriteLine("yes sum " + sumLeft); }
  33.  
  34.             else
  35.  
  36.             {
  37.                 int diff = Math.Abs(sumRight - sumLeft);
  38.                 Console.WriteLine("no diff " + diff);
  39.             }
  40.  
  41.  
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment