Advertisement
loter

Untitled

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