NedyalkoKikov

LeftAdnRightSide

Apr 29th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace LeftAndRighSide
  8. {
  9. class LeftAndRightSide
  10. {
  11. static void Main(string[] args)
  12. {
  13. int left = int.Parse(Console.ReadLine());
  14. int leftSum = 0;
  15. int rightSum = 0;
  16. for (int i = 0; i < left; i++)
  17. {
  18. int n = int.Parse(Console.ReadLine());
  19. leftSum += n;
  20. }
  21. for (int i = 0; i < left; i++)
  22. {
  23. int n = int.Parse(Console.ReadLine());
  24. rightSum += n;
  25. }
  26. int leftAndRight = Math.Abs(leftSum - rightSum);
  27.  
  28. if(leftAndRight == 0)
  29. {
  30. Console.WriteLine("Yes, sum = {0}", rightSum);
  31. }
  32. else
  33. {
  34. Console.WriteLine("No, diff = {0}", leftAndRight);
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment