zoukankan      html  css  js  c++  java
  • 找出字符串中字符出现次数最的字符

    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());


     

  • 相关阅读:
    算法分析实验题集
    程序猿怎样解除烦恼
    MYSQL设计优化
    模式匹配KMP
    ios创建画笔的样例(双笔画效果)
    命令行解析器
    作业还是作孽?——Leo鉴书79
    客户机增加域 及server文件共享
    MySQL教程及经常使用命令1.1
    jsTree插件简介(三)
  • 原文地址:https://www.cnblogs.com/benwu/p/1486426.html
Copyright © 2011-2022 走看看