csharp基础练习题:老switcheroo【难度:1级】:
写一个函数
vowel2index(STR)
vowel2index(STR)
vowel_2_index
vowel_2_index
Vowel2Index(字符串s)
vowel2Index(字符串或多个)
取入的字符串和替换所有的元音[A,E,I,O,U]与字符串内它们各自的位置.
E.g:
vowel2index( '这是我的字符串')== '6S我str15ng th3s'
vowel2index( 'Codewars是世界上最好的网站')== 'C2d4w6rs 10S TH15 b18st s23t25 27N TH32 w35rld'
vowel2index( '')== ''
vowel_2_index( '这是我的字符串')== '6S我str15ng th3s'
vowel_2_index( 'Codewars是世界上最好的网站')== 'C2d4w6rs 10S TH15 b18st s23t25 27N TH32 w35rld'
vowel_2_index( '')== ''
vowel_2_index( '这是我的字符串')== '6S我str15ng th3s'
vowel_2_index( 'Codewars是世界上最好的网站')== 'C2d4w6rs 10S TH15 b18st s23t25 27N TH32 w35rld'
vowel_2_index( '')== ''
vowel2index"这是我的字符串" =="th3s 6S我str15ng"
vowel2index 'Codewars是世界上最好的网站' == 'C2d4w6rs 10S TH15 b18st s23t25 27N TH32 w35rld'
vowel2index '' == ''
Kata.Vowel2Index( "这是我的字符串")== "th3s 6S我str15ng"
Kata.Vowel2Index( "Codewars是世界上最好的网站")== "C2d4w6rs 10S TH15 b18st s23t25 27N TH32 w35rld"
Kata.Vowel2Index( "这是我的字符串")== "th3s 6S我str15ng"
Kata.Vowel2Index( "Codewars是世界上最好的网站")== "C2d4w6rs 10S TH15 b18st s23t25 27N TH32 w35rld"
vowel2Index"这是我的字符串" =="th3s 6S我str15ng"
vowel2Index "Codewars是世界上最好的网站" == "C2d4w6rs 10S TH15 b18st s23t25 27N TH32 w35rld"
您函数应不区分大小写的元音.
编程目标:
public class Kata
{
public static string Vowel2Index(string str)
{
//code me
}
}
测试样例:
using NUnit.Framework;
[TestFixture]
public class Tests
{
[Test]
[TestCase("this is my string", ExpectedResult="th3s 6s my str15ng")]
[TestCase("Codewars is the best site in the world", ExpectedResult"C2d4w6rs 10s th15 b18st s23t25 27n th32 w35rld")]
[TestCase("Tomorrow is going to be raining", ExpectedResult="T2m4rr7w 10s g1415ng t20 b23 r2627n29ng")]
public static string FixedTest(string str)
{
return Kata.Vowel2Index(str);
}
}
最佳答案(多种解法):
更多关联题目:
csharp基础练习题:猫年,狗年【难度:0级】–景越C# 经典编程题库,不同难度C# 练习题,适合自学C# 的新手进阶训练
免责申明
本博客所有编程题目及答案均收集自互联网,主要用于供网友学习参考,如有侵犯你的权益请联系管理员及时删除,谢谢
题目收集至https://www.codewars.com/
https://www.codewars.com/kata/the-old-switcheroo