Advertisement
NelIfandieva

KindsOfSums_Problem04_Test_31Oct2019

Nov 5th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _4
  4. {
  5.     class Program
  6.     {
  7.         //var
  8.         static void Main()
  9.         {
  10.             int[] arrOfInts = new int[10];
  11.             int sumOdd = 0;
  12.             int sumEven = 0;
  13.  
  14.             for(int i = 0; i < arrOfInts.Length; i++)
  15.             {
  16.                 int num = int.Parse(Console.ReadLine());//8
  17.  
  18.                 if(num % 2 != 0 || num == 0)
  19.                 {
  20.                     sumOdd += num;
  21.                 }
  22.                 else
  23.                 {
  24.                     arrOfInts[i] = num;
  25.                     sumEven += arrOfInts[i];
  26.                 }
  27.             }
  28.  
  29.             if(sumOdd == sumEven)
  30.             {
  31.                 Console.Write("Both sums equal {0}", sumOdd);
  32.             }
  33.             else
  34.             {
  35.                 Console.Write("The difference between the sums is {0}", Math.Abs(sumOdd - sumEven));
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement