daily pastebin goal
41%
SHARE
TWEET

Лява и дясна сума :for Loops

bacco Jan 29th, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace tESt
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             int number = int.Parse(Console.ReadLine());
  11.  
  12.             int leftSum = 0;
  13.             int rightSum = 0;
  14.  
  15.             for (int i = 0; i < number; i++)
  16.             {
  17.                 int num = int.Parse(Console.ReadLine());
  18.                 leftSum += num;
  19.             }
  20.             for (int i = 0; i < number; i++)
  21.             {
  22.                 int num = int.Parse(Console.ReadLine());
  23.                 rightSum += num;
  24.             }
  25.             if (leftSum == rightSum)
  26.             {
  27.                 Console.WriteLine("Yes sum = {0}", rightSum);
  28.             }
  29.             else
  30.             {
  31.                 var diff = leftSum - rightSum;
  32.                 Console.WriteLine("No, diff = {0}", Math.Abs(diff));
  33.             }
  34.         }
  35.     }
  36. }
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top