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);
                }
            }
  • 相关阅读:
    CODE[VS] 3026 恶心的扑克
    CODE[VS] 2951 打字比赛
    CODE[VS] 2774 火烧赤壁
    CODE[VS] 1860 最大数 1998年NOIP全国联赛提高组
    matplotlib学习笔记(一)
    LUNA16数据集(二)肺结节可视化
    [转载]pytorch自定义数据集
    [转载]什么情况下应该设置 cudnn.benchmark = True?
    pytorch构建优化器
    pytorch批训练数据构造
  • 原文地址:https://www.cnblogs.com/qixue/p/1666034.html
Copyright © 2011-2022 走看看