Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Arrays
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- int[] numbers = input.Split(" ").Select(int.Parse).ToArray();
- //"2 3 4 5 6 1" -> ["2", "3", "4", "5", "6", "1"] ->
- //-> [2,3,4,5,6,1]
- int sum = 0;
- int min = int.MaxValue; //256575....
- int max = int.MinValue; //-223423423....
- for (int index = 0; index <= numbers.Length - 1; index++)
- {
- int currentNumber = numbers[index];
- sum += currentNumber;
- if(currentNumber < min)
- {
- min = currentNumber;
- }
- if(currentNumber > max)
- {
- max = currentNumber;
- }
- }
- Console.WriteLine("Sum = " + sum);
- double average = sum * 1.0 / numbers.Length;
- Console.WriteLine("Average = " + average);
- Console.WriteLine("Min = " + min);
- Console.WriteLine("Max = " + max);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment