C# 中特定单词的概率大写

  • 本文关键字:概率 单词 c#
  • 更新时间 :
  • 英文 :


我想要这个词大写的所有概率算法hgmsolgomd

我尝试了这段代码,但这转换了单词,而不是一个字母一个字母,也不是所有的概率

string name = "hgmsolgomd";
for (int i = 0; i < name.Length; i++)
{
string newName = name.ToUpper();
}

这是正确答案 可能重复。下面的帖子有大写排列的代码:stackoverflow.com/questions/905317/... - 这应该可以满足您的需求。– 大卫·坦西 7 小时前

即使只有一个大写字母也包含可能性组合,那么:

string text = "hgmsolgomd";
int possibilitiesForAllCaps = (int)Math.Pow(2, text.Length) - 1;

有"减1",因为"hgmsolgomd"不算数,但说"hgmsolgomD"可以。

最新更新