#include
#include
using namespace std;
const string button[10] = {"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
struct wordMap {
string word;
int p;
};//词典的数据结构,是一种映射关系,单词映射到次数(频率)
wordMap dic[1000];
//词典数组
wordMap words[1000];
int total;
int count(string str)
{
int sum = 0;
for (int i = 0; i < total; ++i)
{
if (dic[i].word.substr(0, str.size()) == str)
//将字典里的单词分割成和传入参数一样长的字符串,检测是否相同
sum = sum + dic[i].p;
//相同的话把权重加上
}
return sum;
}
void calculate(string str)
{
wordMap newWords[1000];
//存放本次单词的前缀
int total = 1;
<