[cpp]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#define N 256
void printLetterFreq(char *line)
{
int hash[N] = {0}; //對應於ascII
int i, j;
for (i = 0; i < strlen(line); i++)
{
hash[line[i]]++; //計算相同字符個數
}
for (i = 0; i < N; i++)
{
if (hash[i]) //該字符出現過
{
if(isspace(hash[i])==0&&isblank(hash[i])==0)
{
printf("%c|-", i);
for (j = 0; j < hash[i]; j++) //字母出現的次數
printf("*");
printf("\n");
}
}
}
}
int main()
{
char p[]=
"To recap, the three main objectives in the Mystery Method are: \
To attract a woman \
To establish comfort, trust, and connection \
To structure the opportunity to be seduced ";
printLetterFreq(p);
return 0;