csharp基础练习题:老switcheroo【难度:1级】--景越C#经典编程题库,不同难度C#练习题,适合自学C#的新手进阶训练

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值