Advertisement
SomeoneX

Homework - 04. Equal Pairs

Nov 14th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 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 Homework___04.Equal_Pairs
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int counNum = int.Parse(Console.ReadLine());
  14.  
  15. int sum = 0;
  16. int prevSum = 0;
  17. int diff = 0;
  18. int maxDiff = 0;
  19.  
  20. for (int i = 0; i < counNum; i++)
  21. {
  22. sum += int.Parse(Console.ReadLine());
  23. sum += int.Parse(Console.ReadLine());
  24.  
  25. if (i>0)
  26. {
  27. diff = Math.Abs(sum - prevSum);
  28. }
  29.  
  30. if (diff > maxDiff)
  31. {
  32. maxDiff = diff;
  33. }
  34.  
  35. prevSum = sum;
  36.  
  37. sum = 0;
  38. }
  39.  
  40. if (maxDiff == 0)
  41. {
  42. Console.WriteLine($"Yes, value={prevSum}");
  43. }
  44. else
  45. {
  46. Console.WriteLine($"No, maxdiff={maxDiff}");
  47. }
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement