JulianJulianov

EvenAndOddSubtraction

Feb 3rd, 2020
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _6EvenAndOddSubtraction
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int[] numbers = Console.ReadLine().Split(" ",StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
  11.  
  12. int sumEven = 0;
  13. int sumOdd = 0;
  14. for (int i = 0; i < numbers.Length; i++)
  15. {
  16. int currentNumber = numbers[i];
  17. if (currentNumber %2 == 0)
  18. {
  19. sumEven += currentNumber;
  20. }
  21. else
  22. {
  23. sumOdd += currentNumber;
  24. }
  25. }
  26. Console.WriteLine(sumEven - sumOdd);
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment