• 找出字符串中字符出现次数最的字符


    Code

                for (int i = 0; i < count ;i++)
                {
                    char c = testStr[i];
                    if (cCurrent != c && !list.Contains(c))
                    {
                        list.Add(c); //保存己经出现的字符
                        int scount = 0;
                        for (int j = 0; j < count; j++)//统计
                        {
                            if (testStr[j] == c)
                                scount++;
                        }
                        if (scount > max)
                        {
                            max = scount;
                            cCurrent = c;
                        }
                    }
                }
                Consolse.Write("最长字符串:"+ cCurrent.ToString() + ";长度为" + max.ToString());


     

  • 相关阅读:
    Centos7安装Python3
    mysql+centos7+主从复制
    Python开发之virtualenv和virtualenvwrapper详解
    Linux基础系统优化(二)
    Linux基础系统优化(一)
    Windows 10版本区别
    HTML5常用的语义化标签
    关于efk多服务器多日志合并收集
    离线状态安装docker容器
    Docker部署jenkins+sonar+gitlab代码检测系统
  • 原文地址:https://www.cnblogs.com/benwu/p/1486426.html
Copyright © 2020-2023  润新知