突如其来的变化

来源:互联网 发布:润知文化传播有限公司 编辑:程序博客网 时间:2024/05/01 01:31

描述:

给你一个由”a”,”b”,”c”三个字符组成的字符串,将其中的a替换成b,b替换成a,c保持不变

例如:

‘acb’ –> ‘bca’
‘aabacbaa’ –> ‘bbabcabb’

MyCode:

public class Kata{  public static string Switcheroo(string x)  {    string y = x.Replace("a","d");    string z = y.Replace("b","a");    string retStr = z.Replace("d","b");    return retStr;  }}

CodeWar:

public class Kata{  public static string Switcheroo(string x)  {    return x.Replace("a","d").Replace("b","a").Replace("d","b");  }}
0 0
原创粉丝点击