C語言實現的統計乙個單詞在文章中的頻率

2021-08-09 05:19:45 字數 747 閱讀 8468

單詞用char陣列存,文章也是用char陣列儲存

通過空格找到文章中的各個單詞位置,然後擷取出來各個單詞,同時用傳進去的單詞與擷取的單詞相比較,相同就統計次數+1

函式int wordinpage(char word,char *page)傳進去文章及單詞,返回單詞出現的次數

這個函式比較有難度,因為需要考慮到各種情況

函式char *cutwords(char *page,int start,int end)

word[pos] = '\0';

return word;

}

用作切詞

#include 

#include

char *cutwords(char *page,int start,int end)

word[pos] = '\0';

return word;

}int wordinpage(char word,char *page)

else

if(i==0 && page[0]!=' ')

}else

if(flag==1)

}if(flag==2)}}

printf("the frequency is %d\n",count);

}int main()

c語言 實現乙個棧

include include include include 入棧出站操作 typedef struct nodenode,pnode typedef struct stack pstack,stack void init pstack void push pstack,int bool isem...

C語言 實現乙個通訊錄

可以增容 通訊錄可以用來儲存無上限數量的人的資訊,每個人的資訊包括 姓名 性別 年齡 住址 新增聯絡人資訊 刪除指定聯絡人資訊 查詢指定聯絡人資訊 修改指定聯絡人資訊 顯示所有聯絡人資訊 清空所有聯絡人 排序所有聯絡人 ifndef contact h define contact h includ...

c語言實現乙個進製轉換程式

可以實現常見的進製轉換,例如將十進位制轉換成八進位制等形式。下面是實現 include stdafx.h include math.h include stdlib.h int tmain int argc,tchar argv else if choose 2 else if choose 3 e...