ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

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

2019-09-22 22:00:25  阅读:304  来源: 互联网

标签:练习题 C# 比利 countCombinations Kata CountCombinations 难度


csharp基础练习题:查找组合【难度:1级】:

你的目标是计数的字母或符号某个词或组合出现了多少次在字符串中.关键是不区分大小写,可以在字符串中出现的许多或几十倍.该函数声明为您提供的并且应该有两个参数与返回计数一个返回变量.叠词不应该算作一次以上!空字符串不能是一个关键.该功能还应该能算整数和字符数.认真想!

例:

countCombinations("我的名字叫比利和比利是真棒","比利"); // 2
countCombinations( 'abcdefghijklmonopolymonorailqrstuv', '单'); // 2
countCombinations( 'GrEggreGGREGgREG', '格雷格'); // 4
countCombinations( '@#$ ## @@@', '@'); // 4
countCombinations( '哇什么', '是的'); // 0
countCombinations( 'lololololol', '洛尔'); // 3
countCombinations( '93049', '\\ d'); // 5
countCombinations( '五', '\'); // 5

Kata.CountCombinations("我的名字叫比利和比利是真棒","比利"); // 2
Kata.CountCombinations( "abcdefghijklmonopolymonorailqrstuv", "单声道"); // 2
Kata.CountCombinations( "GrEggreGGREGgREG", "格雷格"); // 4
Kata.CountCombinations( "@#$ ## @@@", "@"); // 4
Kata.CountCombinations( "哇什么", "是啊"); // 0
Kata.CountCombinations( "lololololol", "笑"); // 3
Kata.CountCombinations( "93049",@ "\\ d"); // 5
Kata.CountCombinations( "五个一",@ "\"); // 5

请给予反馈和排名!这将是惊人的!

编程目标:

public class Kata
{
  public static int CountCombinations(string text, string key)
  {
    return 0;
  }
}


测试样例:

namespace Solution 
{
  using NUnit.Framework;
  using System;  
  [TestFixture]
  public class KataTests
  {
    [Test]
      Assert.AreEqual(3, Kata.CountCombinations("hellohellohello", "hello"), "Try again! These words don't need spaces in between.");
    }
  }
}


最佳答案(多种解法):

点击查看答案

更多关联题目:

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

免责申明

本博客所有编程题目及答案均收集自互联网,主要用于供网友学习参考,如有侵犯你的权益请联系管理员及时删除,谢谢
题目收集至https://www.codewars.com/
https://www.codewars.com/kata/find-the-combination

标签:练习题,C#,比利,countCombinations,Kata,CountCombinations,难度
来源: https://blog.csdn.net/weixin_45444821/article/details/101174345

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有