public class Solution {
public string ToGoatLatin(string S)
{
String [] words = S.Split(' ');
List<char> vowel = new List<char>()
{
'a','e','i','o','u','A','E','I','O','U'
};
StringBuilder ans = new StringBuilder();
StringBuilder a = new StringBuilder();
foreach(string s in words) //s 正常
{
List<char> change_word = s.ToList();
if (vowel.IndexOf(change_word[0])==-1)
{
change_word.Insert(change_word.Count,change_word[0]);
change_word.RemoveAt(0);
}
a.Append("a");
ans.Append(" " + change_word.ToString() + "ma" + a);
}
return ans.Remove(ans.Length," " ).ToString() ;
}
}
目前COMPLIER 是過的,但怎麼修改答案都是
" System.Collections.Generic.List`1[System.Char]maa
System.Collections.Generic.List`1[System.Char]maaa
System.Collections.Generic.List`1[System.Char]maaaa
System.Collections.Generic.List`1[System.Char]maaaaa"
但若以input "I speak Goat Latin" 為例,應該是要為
「 Imaa peaksmaaa oatGmaaaa atinLmaaaa」
第一次在板上發文,請各位大大解惑 感謝<(__ )>