Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace OddEvenSum
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num = int.Parse(Console.ReadLine());
- int evenSum = 0;
- int oddSum = 0;
- for (int i = 0; i < num; i++)
- {
- int sum = int.Parse(Console.ReadLine());
- if (i % 2 != 0)
- {
- oddSum += sum;
- }
- else
- evenSum += sum;
- }
- if (evenSum == oddSum)
- {
- Console.WriteLine("Yes");
- Console.WriteLine($"Sum = {evenSum}");
- }
- else
- {
- Console.WriteLine("No");
- Console.WriteLine($"Diff = {Math.Abs(evenSum - oddSum)}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement