統計多字符出現次數

 

  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.     } 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章