Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 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 EqualNumbers
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var count = int.Parse(Console.ReadLine());
  14. double previousPairSum = 0;
  15. double currentPairSum = 0;
  16. double difference = 0;
  17. double biggestdifference = 0;
  18. for (int i = 0; i < count; i++)
  19. {
  20. var num1 = int.Parse(Console.ReadLine());
  21. var num2 = int.Parse(Console.ReadLine());
  22. if (i == 0)
  23. {
  24. previousPairSum = num1 + num2;
  25. }
  26. else
  27. {
  28. currentPairSum = num1 + num2;
  29. difference = Math.Abs(currentPairSum - previousPairSum);
  30. if (difference > biggestdifference)
  31. {
  32. difference = biggestdifference;
  33. }
  34. previousPairSum = currentPairSum;
  35. }
  36. if (biggestdifference == 0)
  37. {
  38. Console.WriteLine("Yes, value = {0}", previousPairSum);
  39. }
  40. else
  41. {
  42. Console.WriteLine("No, diff = {0}", biggestdifference);
  43. }
  44. }
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement