Advertisement
zh_stoqnov

HalfSum EXAM PREPERATION START

Oct 23rd, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. namespace Half_Sum
  4. {
  5. class HalfSum
  6. {
  7. public static void Main(string[] args)
  8. {
  9. int n = int.Parse(Console.ReadLine());
  10. Console.WriteLine();
  11. int[] first = new int[n];
  12. for(int i = 0; i < n; i++)
  13. {
  14. first[i] = int.Parse(Console.ReadLine());
  15. }
  16. int[] second = new int[n];
  17. Console.WriteLine();
  18. for(int i = 0; i < n; i++)
  19. {
  20. second[i] = int.Parse(Console.ReadLine());
  21. }
  22. if(first.Sum() == second.Sum())
  23. {
  24. Console.WriteLine("Yes, sum=" + first.Sum());
  25. }
  26. else
  27. {
  28. Console.WriteLine("No, diff={0}", Math.Max(first.Sum(), second.Sum()) - Math.Min(first.Sum(), second.Sum()));
  29. }
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement