Advertisement
Yanislav29

Untitled

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