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;
- class HalfSum
- {
- static void Main()
- {
- int n, firstNumber, secondNumber;
- int firstSum = 0;
- int secondSum = 0;
- do
- {
- n = int.Parse(Console.ReadLine());
- } while ((n >= 0)^(n <= 500));
- for (int i = 0; i < n; i++)
- {
- do
- {
- firstNumber = int.Parse(Console.ReadLine());
- } while ((firstNumber >= -500000)^(firstNumber <= 500000));
- do
- {
- secondNumber = int.Parse(Console.ReadLine());
- } while ((secondNumber >= -500000) ^ (secondNumber <= 500000));
- firstSum += firstNumber;
- secondSum += secondNumber;
- }
- if (firstSum == secondSum)
- {
- Console.WriteLine("Yes, sum="+ firstSum);
- }
- else
- {
- int difference;
- if (firstSum > secondSum)
- {
- difference = firstSum - secondSum;
- }
- else
- {
- difference = secondSum - firstSum;
- }
- Console.WriteLine("No, diff="+difference);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement