zoukankan      html  css  js  c++  java
  • 统计字符出现的次数

    代码
            static void ReturnShowCOunt(string inputStr)
            {
                
    if (string.IsNullOrEmpty(inputStr))
                    
    throw new ArgumentNullException("inputStr");

                
    for (int i = 0; i < inputStr.Length; i++)
                {
                    
    int flag = 0;
                    
    int count = 1;

                    
    for (int j = 0; j < i; j++)
                    {
                        
    if (inputStr[i] == inputStr[j])
                        {
                            flag 
    = 1;
                            
    break;
                        }                    
                    }

                    
    if (flag == 1)
                        
    continue;

                    
    for (int k = i + 1; k < inputStr.Length; k++)
                    {
                        
    if (inputStr[i] == inputStr[k])
                            count
    ++;
                    }

                    Console.WriteLine(
    "{0}:{1}", inputStr[i], count);
                }
            }
  • 相关阅读:
    HTML5学习
    Python随手记
    Python学习之warn()函数
    Redis学习
    多线程--wait()和notify(),Thread中的等待和唤醒方法
    Interrupt中断线程注意点
    Thread中yield方法
    mysql创建唯一索引,避免数据重复插入
    Jquery自动补全插件的使用
    linux ssh免密登陆远程服务器
  • 原文地址:https://www.cnblogs.com/qixue/p/1666034.html
Copyright © 2011-2022 走看看