Advertisement
desislava_topuzakova

Untitled

Jun 6th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace AlgorithmsOverStructureData
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. string input = Console.ReadLine(); //2 3 4 5 6 7 1
  12. List<int> numbers = input.Split(" ").Select(int.Parse).ToList();
  13. int sum = 0;
  14. int count = 0;
  15.  
  16. foreach(int number in numbers)
  17. {
  18. sum += number;
  19. count++;
  20. }
  21.  
  22. double average = sum * 1.0 / count;
  23.  
  24. Console.WriteLine($"Sum = {sum}; Average = {average:F2}");
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement