Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2016
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace pairs
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14.  
  15. var number = double.Parse(Console.ReadLine());
  16.  
  17. double a = 0;
  18. double b = 0;
  19. double sum = 0;
  20. double tempMin = 0;
  21. double temp2 = 0;
  22. double sum2 = 0;
  23. double max = 0;
  24. double avg = 0;
  25.  
  26.  
  27.  
  28.  
  29. for (int i = 1; i <= number; i++)
  30. {
  31.  
  32. a = double.Parse(Console.ReadLine());
  33. b = double.Parse(Console.ReadLine());
  34.  
  35. sum = a + b;
  36.  
  37. sum2 += sum;
  38.  
  39.  
  40.  
  41. if (i == 1)
  42. {
  43. tempMin = sum;
  44.  
  45. temp2 = sum;
  46. }
  47.  
  48. if (tempMin > sum)
  49. {
  50. tempMin = sum;
  51. }
  52. else if (temp2 < sum)
  53. {
  54. temp2 = sum;
  55. }
  56.  
  57. max = temp2 - tempMin;
  58. avg = max;
  59. if (max < avg)
  60. {
  61. max = avg;
  62. }
  63.  
  64. }
  65.  
  66.  
  67. if ((sum2 / number) == sum)
  68. {
  69. Console.WriteLine("Yes, value={0}", sum);
  70. }
  71. else
  72. {
  73.  
  74. Console.WriteLine("No, maxdiff={0}",max);
  75. }
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement