void printShittyNodes(TreeNode r, int toFind)
{
if (r != null)
{
if (r.getKey( ).isGreaterThan(toFind))
{ printShittyNodes(r.getLeft( ), toFind); }
else { printShittyNodes(v.getRight( ), toFind); }
}
}
最初由 陪你去看龙卷风 发布
its in java code, but also most the same idea about c++, good luck
代码:void printShittyNodes(TreeNode r, int toFind) { if (r != null) { if (r.getKey( ).isGreaterThan(toFind)) { printShittyNodes(r.getLeft( ), toFind); } else { printShittyNodes(v.getRight( ), toFind); } } }
int count ( char *voteArray, int highIndex, int lowIndex )
{
int toReturn = 0;
if (highIndex != lowIndex)
{
if (voteArray[highIndex] == 'Y')toReturn += 1;
else toReturn -= 1;
(if voteArray[lowIndex] == 'Y') toReturn += 1;
else toReturn -= 1;
toReturn += count(voteArray,highIndex-1,lowIndex+1);
} return toReturn;
}
最初由 陪你去看龙卷风 发布
草稿, indexing array element那块可能错了,顺便问一句........大哥阿,你上课去了吗?
int count (char*voteArray, int highIndex, int lowIndex) {
if (highIndex - lowIndex < 0) return 0;
else {
if (voteArray[highIndex] == Y)
return (count(voteArray, highIndex - 1, lowIndex) + 1;
else
return (count(voteArray, highIndex - 1, lowIndex) - 1;
}
}
最初由 风中有影 发布
void TreeNode::subprint (TreeNode *subRoot,int n) {
if(subRoot->key<n) return;
subPrint (subRoot -> left,n);
cout << subRoot -> key << endl;
subPrint (subRoot -> right,n);
}
最初由 风中有影 发布
我的CODE向左走,向右走的情况都包了的.
在次,RETURN以后,为什么我还要COUT在RETURN的后面的东西.RETURN代表结束,难道我们学的C++不一样?