64,281
社区成员
发帖
与我相关
我的任务
分享
const char * strs[] = {
"ape", "apes", "apse", "asp", "pas", "pase", "pea",
"peas", "pes", "sae", "sap", "sea", "spa", "spae"
};
Boggle A;
A.solve(strs);
void Boggle::Solve( const char * a_Grid) const
{
在这里把他们一个一个的打出来 a_Grid 里面的东东
}
template <int N>
void solve(const char *(&strs)[N])
{
for (int i = 0; i < N; ++i) {
cout << strs[i] << endl;
}
}
char* strs;
...
do {
while(*strs){
//do something.
strs++;
};
strs++;
}while(*strs);
const char * strs[] = {
"ape", "apes", "apse", "asp", "pas", "pase", "pea",
"peas", "pes", "sae", "sap", "sea", "spa", "spae"
};//strs[]是常量char型指针的数组,即数组中的每一个元素都指向一个常量字符串
const char * strs[] = {
"ape", "apes", "apse", "asp", "pas", "pase", "pea",
"peas", "pes", "sae", "sap", "sea", "spa", "spae",NULL //加一个NULL表示结束,可以用0
};
Boggle A;
A.solve(strs);
void Boggle::Solve( const char ** a_Grid) const
{
assert(a_Grid);//断言指针非空,传入空指针,调试出错。
if(!a_Grid)return ;//保证指针非空。
//在这里把他们一个一个的打出来, a_Grid 里面的东东。
while(*a_Gird){
std::cout<<*a_Gird++ <<std::endl;
}
}
while (a_Grid)
{
string word( (*a_Grid)[0],&(a_Grid)[strlen(*a_Grid)]);
a_Grid++;
this->T->Insert_A_Word(word);
}