verito898

Half Sum * Second

Jul 8th, 2014
585
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.  
  3. class HalfSum
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.         int firstNumb = 0;
  9.         int secondNumb = 0;
  10.         int firstSum = 0;
  11.         int secondSum = 0;
  12.         for (int i = 1; i <=n; i++)
  13.         {
  14.             firstNumb = int.Parse(Console.ReadLine());
  15.             firstSum = firstSum + firstNumb;
  16.         }
  17.         for (int j = 1; j <=n; j++)
  18.         {
  19.             secondNumb = int.Parse(Console.ReadLine());
  20.             secondSum = secondSum + secondNumb;
  21.         }
  22.         if (firstSum == secondSum)
  23.         {
  24.             Console.WriteLine("Yes, sum ={0}",firstSum);
  25.         }
  26.         else if (firstSum>secondSum)
  27.         {
  28.             Console.WriteLine("No, diff ={0}",Math.Abs(firstSum-secondSum));
  29.         }
  30.         else if (secondSum>firstSum)
  31.         {
  32.              Console.WriteLine("No, diff ={0}",Math.Abs(secondSum-firstSum));
  33.         }
  34.     }
  35. }
Add Comment
Please, Sign In to add comment