fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication3
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. Random rnd = new Random();
  13. var items = Enumerable.Range(1, 100).Select(a => rnd.Next(100)).ToList();
  14.  
  15. //(1)100個の、1~100からなる数字列
  16. items.ForEach(a => Console.Write(a + ","));
  17. Console.WriteLine("\n---");
  18.  
  19. //(2)重複を除いて、昇順で表示
  20. items.Distinct().OrderBy(a => a).ToList().ForEach(a => Console.Write(a + ","));
  21. Console.WriteLine("\n---");
  22.  
  23. //(3)合計と平均
  24. Console.WriteLine("合計 " + items.Sum());
  25. Console.WriteLine("平均 " + items.Average());
  26.  
  27.  
  28. }
  29. }
  30. }
  31.  
Success #stdin #stdout 0.05s 37232KB
stdin
Standard input is empty
stdout
35,69,41,24,32,93,74,67,50,48,46,42,12,53,62,39,3,52,84,22,55,31,73,67,26,76,51,38,85,96,10,2,11,61,26,20,51,39,92,45,78,5,37,84,50,96,19,60,88,53,12,67,77,15,50,32,58,79,97,12,41,35,74,4,70,40,4,27,3,66,19,43,64,31,10,88,54,57,16,94,18,72,41,73,55,74,27,6,91,85,15,24,35,26,25,35,40,6,74,61,
---
2,3,4,5,6,10,11,12,15,16,18,19,20,22,24,25,26,27,31,32,35,37,38,39,40,41,42,43,45,46,48,50,51,52,53,54,55,57,58,60,61,62,64,66,67,69,70,72,73,74,76,77,78,79,84,85,88,91,92,93,94,96,97,
---
?? 4695
?? 46.95