#include<iostream>
template<typename T>
struct node
{
T data;
node* left {nullptr};
node* right {nullptr};
node (const T& value): data (value) {}
~node () { delete left; delete right; }
void insert (const T& value)
{
if (value < data)
{
if (left)
left->insert (value);
else
left = new node (value);
}
else
{
if (right)
right->insert (value);
else
right = new node (value);
}
}
};
template<typename T>
struct bin_tree
{
node<T>* root {nullptr};
~bin_tree () { delete root; }
void insert (const T& value)
{
if (!root)
root = new node<T> (value);
else
root->insert (value);
}
};
template<typename T>
std::ostream& operator<< (std::ostream& os, const node<T>& n)
{
if (n.left) os << (*n.left);
os << n.data << ' ';
if (n.right) os << (*n.right);
return os;
}
template<typename T>
std::ostream& operator<< (std::ostream& os, const bin_tree<T>& t)
{
if (t.root)
return os << (*t.root);
return os;
}
int main()
{
int arr[10] = {42, 56, 30, 5, 12, 60, 40, 8, 1, 99};
bin_tree<int> tree;
for (size_t e=0; e!=10; ++e)
tree.insert (arr[e]);
std::cout << tree << std::endl;
}
By execution time, the code has already been translated into binary ("compiled"). However, the program may still rely on outside libraries (.dlls for example) that have also been pre-compiled.
A source code file is a plain-text file containing C++ instructions. The instructions must be compiled and linked to create a native machine code executable.
If people started writing these codes here, then what software engineers will do?
The Hero Code is NNNNN NNNNN NNNNN NNNNN and the Ring code is dependent on your linked game.
yes it can very much so read binary.
Use inline assembly instructions. Then compile your C++ program to produce the machine code.
1 plus 1 = 2
There is no unary plus in C, but if there were, it would have only one operand, unlike the binary plus which has two: x = a + b; /* binary plus */ x = + b; /* unary plus -- not in C*/ x = a - b; /* unary plus */ x = - b; /* unary minus */
1 + 1 = 10 in binary numbers.
No. Neither C nor C++ are interpreted. Both need to be compiled and linked to produce highly-optimised machine code, which is then executed.
2 decimal, or 10 binary.
easy, 1011. in binary of course. convert 1011 binary to decimal you get 11.