Krasimir_Slavov

Untitled

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