Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DomashnoEvenOrOdd
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int eventSum = 0;
- int oddtSum = 0;
- for (int i = 0; i < n; i++)
- {
- int input = int.Parse(Console.ReadLine());
- if (i % 2 == 1)
- {
- eventSum += input;
- }
- else
- {
- oddtSum += input;
- }
- }
- if (eventSum == oddtSum)
- {
- Console.WriteLine($"Yes");
- Console.WriteLine($"Sum = {eventSum}");
- }
- else
- {
- int difference = eventSum - oddtSum;
- Console.WriteLine($"No");
- Console.WriteLine($"Diff = {Math.Abs(difference)}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement