zoukankan      html  css  js  c++  java
  • 查询字符串中字母出现的个数

    /*查询字符串中字母出现的个数*/
                string str = " Welcom Hello World";
                Dictionary<char, int> dc = new Dictionary<char, int>();
                for (int i = 0; i < str.Length; i++) //遍历字符串的长度
                {
                    if (str[i] == ' ')
                    {
                        continue;
                    }
                    if (!dc.ContainsKey(str[i]))
                        {
                        dc.Add(str[i], 1);
                    }
                    else
                    {
                        dc[str[i]]++;
                    }
                }
                foreach (KeyValuePair<char,int> kv in dc)
                {
                    Console.WriteLine("{0},{1}", kv.Key,kv.Value);
                }
                Console.ReadKey();

  • 相关阅读:
    RFM模型
    mysql日期函数(时间函数)
    数据库探索
    anaconhda安装步骤
    mysql安装和环境配置
    mysql时间条件查询
    mysql自连接
    mysql查询注意事项(查询优化)
    mysql常见的保留字和反引号使用
    多表联合查询注意事项(索引)
  • 原文地址:https://www.cnblogs.com/haimingkaifa/p/5386695.html
Copyright © 2011-2022 走看看