Yachkov

left and right sum

Jan 31st, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. using System;
  2. using System.ComponentModel;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.ComponentModel.Design;
  5. using System.Globalization;
  6. using System.Net.Http.Headers;
  7. using System.Reflection;
  8. using System.Runtime.ConstrainedExecution;
  9. using System.Security.Cryptography;
  10.  
  11.  
  12. namespace SomeExcercises
  13. {
  14.     class Program
  15.     {
  16.         static void Main(string[] args)
  17.         {
  18.             int leftSum = 0;
  19.             int rightSum = 0;
  20.             int sum = leftSum + rightSum;
  21.             int n = int.Parse(Console.ReadLine());
  22.  
  23.             for (int i = 0; i < n; i++)
  24.             {
  25.                 int leftNum = int.Parse(Console.ReadLine());
  26.                 leftSum += leftNum;
  27.                
  28.             }
  29.             for (int i = 0; i < n; i++)
  30.             {
  31.                 int rightNum = int.Parse(Console.ReadLine());
  32.                 rightSum += rightNum;
  33.             }
  34.  
  35.             if (leftSum == rightSum)
  36.             {
  37.                 Console.WriteLine($"Yes, sum = {leftSum}");
  38.             }
  39.             else
  40.             {
  41.                 Console.WriteLine($"No, diff = {Math.Abs(leftSum - rightSum)}");
  42.             }
  43.         }
  44.     }
  45. }
  46.  
  47.  
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment