您的位置:首页 > 其它

CodeWars可以学习的

2015-07-03 20:56 337 查看
http://www.codewars.com/kata/54ff3102c1bad923760001f3/solutions/csharp

判断给定的字符串有多少个a e i o u

using System;
using System.Linq;

public static class Kata
{
public static int GetVowelCount(string str)
{
return str.Count(x => "aeiou".IndexOf(x) != -1);
}
}


public static class Kata
{
public static int GetVowelCount(string str)
{
return str.Where(c => new [] {'a','e','i','o','u'}.Any(v => v == c)).Count();
}
}

http://www.codewars.com/kata/5506b230a11c0aeab3000c1f
using System;

public class Evaporator {

public static int evaporator(double content, double evap_per_day, double threshold) {
return (int)Math.Ceiling(Math.Log(threshold / 100.0) / Math.Log(1.0 - evap_per_day / 100.0));
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: