Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 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 Left_And_Right_Sum
  8. {
  9. class Task7
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.Write("n= ");
  14. var n = int.Parse(Console.ReadLine());
  15. Console.WriteLine("Enter the leftside numbers:");
  16. var leftSum = 0;
  17. for (int i = 0; i < n; i++)
  18. {
  19. var num = int.Parse(Console.ReadLine());
  20. leftSum = leftSum + num;
  21. }
  22. Console.WriteLine("Enter the rightside numbers:");
  23. var rightSum = 0;
  24. for (int i = 0; i < n; i++)
  25. {
  26. var num = int.Parse(Console.ReadLine());
  27. rightSum = rightSum + num;
  28. }
  29. var difference = Math.Abs(leftSum - rightSum);
  30. if (difference == 0)
  31. {
  32. Console.WriteLine("Yes, "+("sum = "+leftSum));
  33. }
  34. else
  35. {
  36. Console.WriteLine("No, " + ("difference = " + difference));
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement