fork download
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. Debug.Assert(2 == Keisan(2, "one"));
  12. Debug.Assert(6 == Keisan(2, "one", "two"));
  13. Debug.Assert(12 == Keisan(2, "one", "two", "three"));
  14. Debug.Assert(8 == Keisan(2, "one", "three"));
  15. }
  16.  
  17. static int Keisan(int i, params string[] args) => i * Conv(args).Sum();
  18.  
  19. static IEnumerable<int> Conv(params string[] args)
  20. {
  21. foreach (var item in args)
  22. {
  23. if (item == "one")
  24. {
  25. yield return 1;
  26. }
  27. else if (item == "two")
  28. {
  29. yield return 2;
  30. }
  31. else if (item == "three")
  32. {
  33. yield return 3;
  34. }
  35. }
  36. }
  37. }
Success #stdin #stdout 0.02s 12676KB
stdin
Standard input is empty
stdout
Standard output is empty