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