Advertisement
shady_obeyd

Untitled

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