- int main()
 
 - {
 
 -     char str[] = "Welcome to Chinaworld";
 
 -     int a[50] ; //用于标记字母
 
 -     for (int i = 0; i < strlen(str); i++)
 
 -     {
 
 -         a[i] = 1; //初始化,所有的标记都为1
 
 -     }
 
  
-     for(int i = 0;i < strlen(str);i++)
 
 -     {
 
 -         int count = 1;
 
 -         if (((str[i] >= 'A' && str[i] <= 'Z')||(str[i] >= 'a' && str[i] <= 'z'))&&(a[i] == 1))
 
 -         {
 
 -             if ((str[i] >= 'A' && str[i] <= 'Z')||(str[i] >= 'a' && str[i] <= 'z'))
 
 -             {
 
 -                 for (int j = i+1; j < strlen(str); j++)
 
 -                 {
 
 -                     if ((str[j] >= 'A' && str[j] <= 'Z')||(str[j] >= 'a' && str[j] <= 'z'))
 
 -                     {
 
 -                         if ((str[i] == str[j])||(str[i] == (str[j]-32))||(str[i] == (str[j]+32)))
 
 -                         {
 
 -                             a[j] = 0; //当被计算,归0
 
 -                             count++;
 
 -                             
 
 -                         }
 
 -                     }
 
 -                     
 
 -                 }
 
 -             }
 
 -             
 
 -             printf("%c-%d\n ",str[i],count);
 
 -    
 
 -        }
 
 -     }
 
 -   
 
 -     return 0;
 
 - }
 
  复制代码 |