Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace AlgorithmsOverStructureData
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine(); //2 3 4 5 6 7 1
- List<int> numbers = input.Split(" ").Select(int.Parse).ToList();
- int sum = 0;
- int count = 0;
- foreach(int number in numbers)
- {
- sum += number;
- count++;
- }
- double average = sum * 1.0 / count;
- Console.WriteLine($"Sum = {sum}; Average = {average:F2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement