Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 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. using System.Globalization;
  7.  
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. double n = double.Parse(Console.ReadLine());
  13. double OddSum = 0;
  14. double OddMin = double.MaxValue;
  15. double OddMax = double.MinValue;
  16.  
  17. double EvenSum = 0;
  18. double EvenMin = double.MaxValue;
  19. double EvenMax = double.MinValue;
  20. if (n==1)
  21. {
  22. double num = double.Parse(Console.ReadLine());
  23.  
  24. Console.WriteLine("OddSum={0}", num);
  25. Console.WriteLine("OddMin={0}", num);
  26. Console.WriteLine("OddMax={0}", num);
  27.  
  28. Console.WriteLine("EvenSum=0");
  29. Console.WriteLine("EvenMin=No");
  30. Console.WriteLine("EvenMax=No");
  31. }
  32. else if (n == 0)
  33. {
  34.  
  35. Console.WriteLine("OddSum=0");
  36. Console.WriteLine("OddMin=No");
  37. Console.WriteLine("OddMax=No");
  38.  
  39. Console.WriteLine("EvenSum=0");
  40. Console.WriteLine("EvenMin=No");
  41. Console.WriteLine("EvenMax=No");
  42. }
  43.  
  44.  
  45. else
  46. {
  47. for (int i = 1; i <= n; i++)
  48. {
  49. double num = double.Parse(Console.ReadLine());
  50.  
  51. if (i % 2 != 0)
  52. {
  53. if (num < OddMin)
  54. {
  55. OddMin = num;
  56. }
  57. if (num > OddMax)
  58. {
  59. OddMax = num;
  60. }
  61. OddSum += num;
  62. }
  63. else if (i % 2 == 0)
  64. {
  65. if (num < EvenMin)
  66. {
  67. EvenMin = num;
  68. }
  69. if (num > EvenMax)
  70. {
  71. EvenMax = num;
  72. }
  73. EvenSum += num;
  74. }
  75. }
  76. Console.WriteLine("OddSum={0}", OddSum);
  77. Console.WriteLine("OddMin={0}", OddMin);
  78. Console.WriteLine("OddMax={0}", OddMax);
  79.  
  80. Console.WriteLine("EvenSum={0}", EvenSum);
  81. Console.WriteLine("EvenMin={0}", EvenMin);
  82. Console.WriteLine("EvenMax={0}", EvenMax);
  83. }
  84.  
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement