desislava777

OddEvenSum

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