0
Swap Adjacent letters in a word
Ex:LONDON ->OLDNNO
2 Respostas
+ 1
try this:
StringBuilder builder = new StringBuilder();
string s = "LONDON";
for (int i = 1; i < s.Length; i += 2)
{
builder.Append(s[i]);
builder.Append(s[i - 1]);
}
if (s.Length % 2 == 1)
builder.Append(s.Last()); // if the string has an odd number of characters we
add the last character (which was not swapped)
Console.Write(builder.ToString());
0
Thank you very much .. it's working ....