bt.exe has stopped working
Write your question here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <iostream>
using namespace std;
struct node
{
node *left;
int data;
node *right;
}*root=NULL;
node * add(node *temp,int dat)
{
temp=new node;
temp->data=dat;
temp->left=NULL;
temp->right=NULL;
return temp;
}
int siz(node *node)
{
if(node!=NULL)
{
return(siz(node->left)+1+siz(node->right));
}
else
return 0;
}
int main()
{
add(root,1);
add(root->left,2);
add(root->right,3);
int i=siz(root);
cout<<i;
}
|
What's the point of passing a pointer to add if you never use that pointer's value in the function?
Topic archived. No new replies allowed.