Advertisement
plamen27

Equal Pairs fixed

Aug 2nd, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 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 pairs
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. var number = double.Parse(Console.ReadLine());
  15.  
  16.  
  17. double sum = 0;
  18. double sum2 = 0;
  19. double max = 0;
  20. double avg = 0;
  21.  
  22.  
  23.  
  24.  
  25. for (int i = 1; i <= number; i++)
  26. {
  27. sum2 = sum;
  28. var a = double.Parse(Console.ReadLine());
  29. var b = double.Parse(Console.ReadLine());
  30.  
  31. sum = a + b;
  32.  
  33. if (i == 1)
  34. {
  35. continue;
  36. }
  37. avg = Math.Abs(sum - sum2);
  38.  
  39. if (avg > max)
  40. {
  41. max = avg;
  42. }
  43.  
  44. }
  45.  
  46.  
  47. if (max == 0)
  48. {
  49. Console.WriteLine("Yes, value={0}", sum);
  50. }
  51. else
  52. {
  53.  
  54. Console.WriteLine("No, maxdiff={0}",max);
  55. }
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement