温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

统计多字符出现次数

发布时间:2020-06-17 22:45:47 来源:网络 阅读:293 作者:gexu1990 栏目:编程语言

 

  1. using System; 
  2. using System.Collections.Generic; 
  3. using System.Linq; 
  4. using System.Text; 
  5. using System.Collections; 
  6.  
  7. namespace ConsoleApplication3 
  8.     class Program 
  9.     { 
  10.         static void Main(string[] args) 
  11.         { 
  12.             a(); 
  13.         } 
  14.         public static int a() 
  15.         { 
  16.             string ab; 
  17.             string full = "aaabbbcaaa"
  18.             Hashtable stringTime = new Hashtable(); 
  19.             for (int i = 0; i < full.Length-1; i++) 
  20.             { 
  21.                  
  22.                 int k = 0; 
  23.                  ab = full.Substring(i, 2); 
  24.                 for (int j = 0; j < full.Length-1; j++) 
  25.                 { 
  26.                     string cAb = full.Substring(j, 2); 
  27.                     if (ab.Equals(cAb)) 
  28.                     { 
  29.                         k++; 
  30.                     } 
  31.                 } 
  32.                 if (!stringTime.ContainsKey(ab)) 
  33.                 { 
  34.                     stringTime.Add(ab, k); 
  35.                 } 
  36.             } 
  37.             return 0; 
  38.         } 
  39.          
  40.     } 

 

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI