Advertisement
Guest User

Untitled

a guest
Jan 28th, 2017
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         int inputSize = int.Parse(Console.ReadLine());
  8.        
  9.         if (inputSize == 0)
  10.             Console.WriteLine("OddSum=0, OddMin=no, OddMax=no, EvenSum=0, EvenMin=No, EvenMax=No");
  11.        
  12.         double sumOfOddNums, sumOfEvenNums;
  13.         double minOddNum, maxOddNum;
  14.         double minEvenNum, maxEvenNum;
  15.        
  16.         sumOfOddNums = sumOfEvenNums = 0;
  17.         minOddNum = minEvenNum = double.MaxValue;
  18.         maxOddNum = maxEvenNum = double.MinValue;
  19.        
  20.         for (int i = 1; i <= inputSize; ++i)
  21.         {
  22.             double input = double.Parse(Console.ReadLine());
  23.            
  24.             if (inputSize <= 1)
  25.             {
  26.                 Console.WriteLine("OddSum={0}, OddMin={0}, OddMax={0}, EvenSum=0, EvenMin=No, EvenMax=No", input);
  27.             }
  28.            
  29.             if (i % 2 == 0)
  30.             {
  31.                 sumOfEvenNums += input;
  32.                
  33.                 if (input < minEvenNum)
  34.                     minEvenNum = input;
  35.                
  36.                 if (input > maxEvenNum)
  37.                     maxEvenNum = input;                
  38.             }
  39.            
  40.             else
  41.             {
  42.                 sumOfOddNums += input;
  43.                
  44.                 if (input < minOddNum)
  45.                     minOddNum = input;
  46.                
  47.                 if (input > maxOddNum)
  48.                     maxOddNum = input;    
  49.             }
  50.         }
  51.        
  52.         Console.WriteLine("OddSum={0}, OddMin={1}, OddMax={2}, EvenSum={3}, EvenMin={4}, EvenMax={5}",
  53.                           sumOfOddNums, minOddNum, maxOddNum, sumOfEvenNums, minEvenNum, maxEvenNum);
  54.     }
  55.    
  56.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement