Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class ForEachLoopArray
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int sumOne = 0;
- for (int i = 0; i < n; i++)
- {
- int element = int.Parse(Console.ReadLine());
- sumOne = sumOne + element;
- }
- int sumTwo = 0;
- for (int i = 0; i < n; i++)
- {
- int elementTwo = int.Parse(Console.ReadLine());
- sumTwo = sumTwo + elementTwo;
- }
- if (sumOne == sumTwo)
- {
- Console.WriteLine("Yes, sum={0}", sumOne);
- }
- if (sumOne != sumTwo)
- {
- int diff = Math.Abs(sumOne - sumTwo);
- Console.WriteLine("No, diff={0}", diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement