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


     

  • 相关阅读:
    memcached构建集群分析之一
    linux使用getopt解析参数
    setbuffer和freopen做一个简单的日志组件
    setbuf和freopen
    编码规范的重要性
    c++的操作符格式记录
    do{...}while(0)的作用
    CF div2 321 C
    CF div2 321 B
    CF div2 321 A
  • 原文地址:https://www.cnblogs.com/benwu/p/1486426.html
Copyright © 2011-2022 走看看