using System;using System.Collections.Generic;using System.Linq;publicstaticclassKata{publicstaticintSolve(string str){var result =int.MinValue;var count =0;foreach(var val in str){if("aeiou".Contains(val.ToString())){
count++;if(count > result){
result = count;}}else{
count =0;}}if(result <=0){return0;}return result;}}
答案4:
using System;publicstaticclassKata{publicstaticintSolve(string str){int temp =0;int currMax =0;for(int i =0; i < str.Length; i++){if("aeiou".Contains(str[i])){
temp++;}else{if(temp > currMax){
currMax = temp;}
temp =0;}}//we need to check if the longest chain is at the endreturn Math.Max(temp, currMax);}}
答案5:
using System;publicstaticclassKata{publicstaticintSolve(string str){if(str !=null){int max =0;int vowelCount =0;foreach(char i in str){if("aeiou".Contains(i)){
vowelCount++;if(vowelCount > max){
max = vowelCount;}}else{
vowelCount =0;}}return max;}thrownewArgumentNullException();}}