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 _4.Еднакви_двойки
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- double sumEven = 0;
- double sumOdd = 0;
- double diff = -3333333;
- double max = int.MinValue;
- for (int i = 1; i <= n; i++)
- {
- double num1 = double.Parse(Console.ReadLine());
- double num2 = double.Parse(Console.ReadLine());
- if (i % 2 == 0)
- {
- sumEven = num1 + num2;
- }
- else
- {
- sumOdd = num1 + num2;
- }
- if (i == 1)
- {
- diff = 0;
- }
- else if (i >= 2)
- {
- diff = Math.Abs(sumEven - sumOdd);
- if (diff > max)
- {
- max = diff;
- }
- }
- }
- if (diff == 0)
- {
- Console.WriteLine($"Yes, value={sumOdd}");
- }
- else
- {
- Console.WriteLine($"No, maxdiff={max}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment