Advertisement
marto9119

Untitled

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