日期:2014-05-17 浏览次数:20764 次
static void Main(string[] args)
{
Console.WriteLine(howmany("bibinbing"));
}
static List<char> list_b = new List<char>();
static List<char> list_i = new List<char>();
static List<char> list_n = new List<char>();
static List<char> list_g = new List<char>();
public static int howmany(string s)
{
foreach (char c in s.ToCharArray())
{
list_b.Add(c);
}
int res = 0;
while (list_b.Contains('b'))
{
Remove(list_b, out list_i, 'b');
while (list_i.Contains('i'))
{
Remove(list_i, out list_n, 'i');
while (list_n.Contains('n'))
{
Remove(list_n, out list_g, 'n');
res += list_g.Count(l => l == 'g');
}
}
}
return res;
}
private static void Remove(List<char> list,out List<char> _list,char c)