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 LeftRightSum
- {
- class SumLeftRight
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int leftSum = 0;
- int rightSum = 0;
- //for(int i = 0; i < n; i++)
- //{
- // int currentNumber = int.Parse(Console.ReadLine());
- // leftSum = leftSum + currentNumber;
- //}
- //for(int i = 0; i < n; i++)
- //{
- // int currentNumber = int.Parse(Console.ReadLine());
- // rightSum = rightSum + currentNumber;
- //}
- for(int i = 0; i < 2 * n; i++)
- {
- if(i < n)
- {
- int currentNumber = int.Parse(Console.ReadLine());
- leftSum = leftSum + currentNumber;
- }
- else
- {
- int currentNumber = int.Parse(Console.ReadLine());
- rightSum = rightSum + currentNumber;
- }
- }
- if(leftSum == rightSum)
- {
- Console.WriteLine("Yes, sum = {0}" , leftSum);
- }
- else
- {
- Console.WriteLine("No, diff = {0}" , Math.Abs(leftSum - rightSum));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement