Advertisement
radoslava29

Untitled

May 31st, 2017
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace HalfSumElement
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13.  
  14.  
  15. {
  16. var n = int.Parse(Console.ReadLine());
  17. var max = int.Parse(Console.ReadLine());
  18. int curentNumber = 0;
  19. int sum = 0;
  20.  
  21. for (int i = 1; i < n; i++)
  22. {
  23. curentNumber = int.Parse(Console.ReadLine());
  24. sum = sum + curentNumber;
  25.  
  26. if (curentNumber > max)
  27. {
  28. max = curentNumber;
  29. }
  30. }
  31.  
  32. if (sum - max == max)
  33. {
  34. Console.WriteLine("Yes Sum = " + sum);
  35. }
  36. else
  37. {
  38. Console.WriteLine("No, diff = {0}", Math.Abs(max-(sum - max)));
  39. }
  40.  
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement