slimved3
BAN USERLet me know if the following code works fine with all inputs,
tested few inputs and worked for me not sure if I missed any case..
typedef struct node tNode;
struct node
{
tNode *left;
tNode *right;
int data;
};
int maxdistancebtwnodes(tNode* node, int *dist)
{
if(node == NULL)
{
*dist = 0;
return -1;
}
int lefth=0, righth=0, ldist=*dist, rdist=*dist;
lefth = maxdistancebtwnodes(node->left, &ldist) +1;
righth = maxdistancebtwnodes(node->right, &rdist) +1;
*dist = (ldist>rdist)?ldist:rdist;
if(lefth+righth+1 > *dist)
*dist = lefth+righth+1;
return ((lefth > righth)? lefth: righth);
}
int main()
{
tNode *root;
createyourtree(&root);
int maxdist=0;
maxdistancebtwnodes(root, &maxdist);
}
#include <stdio.h>
int parseandadd(char* str)
{
int spc = 0;
while(str[spc++] != ' ') { }
int ch=spc, num1=0, num2=0, sum=0, numi=0, op=0;
while(!(str[ch] == '+' || str[ch] == '-'))
{
num1 = (num1*10)+(str[numi++] - '0');
++ch;
}
if(str[ch] == '-') op = 1;
else if(str[ch] == '+') op = 0;
else return -1;
ch++;
while(str[ch++] != '\0' && numi < spc)
{
num2 = (num2*10)+(str[numi++] - '0');
}
op?(sum = num1-num2):(sum = num1+num2);
printf("%d %d = %d\n", num1, num2, sum);
//scanf("%d", &spc);
return sum;
}
int main()
{
parseandadd("456123 abc+cde");
return 0;
}
1. Check if the driver for your camera device is installed properly on machine.
- slimved3 October 30, 20172. Check system error messages if any logged after connecting the device.
3. Check cable, ports or hardware related issues if any.