QString SynchronousProcess::locateBinary(const QString &path, const QString &binary) { // Absolute file? const QFileInfo absInfo(binary); if (absInfo.isAbsolute()) { return checkBinary(absInfo.dir(), absInfo.fileName()); } // Windows finds binaries in the current directory if (pathOS == OS_Windows) { const QString currentDirBinary = checkBinary(QDir::current(), binary); if (!currentDirBinary.isEmpty()) { return currentDirBinary; } } const QStringList paths = path.split(pathSeparator()); if (paths.empty()) { return QString(); } const QStringList::const_iterator cend = paths.constEnd(); for (QStringList::const_iterator it = paths.constBegin(); it != cend; ++it) { const QDir dir(*it); const QString rc = checkBinary(dir, binary); if (!rc.isEmpty()) { return rc; } } return QString(); }
void checkBinary(node r) { int flag=0; if(r->left!=NULL) { if((r->data)<((r->left)->data)) { flag=1; return; } checkBinary(r->left); } if(r->right!=NULL) { if((r->data)>=((r->right)->data)) { flag=1; return; } checkBinary(r->right); } if(flag==1) { printf("Not Binary Tree\n"); exit(0); } }
int Numbers::getBinary( string str) { int res_num = 0; if (!checkBinary(str)) return 0; // Check if proper binary. for(int cnt = 2;cnt < str.length( );cnt++) { res_num += pow(2,str.length( ) - (cnt - 1)) * (str[cnt] - '0'); // Ternay operation for getting the proper number. } return res_num; }
void main() { node root=NULL; int ele; while(fscanf(stdin,"%d",&ele)==1) { if(ele==EOF) break; root=createTree(root,ele); } // printinorder(root); checkBinary(root); makefile(root); }