Advertisement
viraco4a

Simple_Loops_Task12

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