int main()//Couting the frequency of word 'the' in a sentence
{
int i,n;
char t,h,e,space;
int wcount=0;
char input[100];
gets(input);
n=strlen(input);
for(i=0;i<=n-3;i++)
{
t=(input[i]=='t' || input[i]=='T');
h=(input[i+1]=='h' || input[i+1]=='H');
e=(input[i+2]=='e' || input[i+2]=='E');
space=(input[i+3]==' ' || input[i+3]=='\0');
if((t&&h&&e&&space)==1)
wcount++;
}
printf("The frequency of word 'the' is %d",wcount);
}
此 C 程序查找给定句子中单词“the”的频率。该程序用于查找给定句子中出现的单词“the”。并显示“该”词出现的次数。
Can someone explain the meaning of statement:
t=(input[i]=='t' || input[i]=='T');
h=(input[i+1]=='h' || input[i+1]=='H');
e=(input[i+2]=='e' || input[i+2]=='E');
space=(input[i+3]==' ' || input[i+3]=='\0');