统计字符出现的次数

代码
        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);
            }
        }
原文地址:https://www.cnblogs.com/qixue/p/1666034.html