Question 1

Write a console program in C language that takes an equation in the form of A + B = C from the standard input. A, B and C are either a number having at most `10` digits or a combination of number and a single number sign (`#`). The number sign is a placeholder for any number with any number of digits. If there exists a sequence of numbers which substitute the `#`, and the equation is valid then the program should write the full equation on the standard output. Otherwise, the program should print `-1` on the standard output. Look at the examples for more information.

Examples

Input Output
10# + 50 = 10052 10002 + 50 = 10052
#2 + 3 = 26 -1
12 + 13 = # 12 + 13 = 25
50 + 1#2 = 10052 50 + 10002 = 10052


Question 2

Implement a binary tree in C language. For simplicity's sake, consider adding unique positive values to the tree. Your data structure should contain the following methods:

  • add_node
  • remove_node
  • search
    • if a value exists in tree return 1 otherwise, 0.
typedef struct < your struct ...> btree_t;

/* Add value to the tree
* return 1 if successful otherwise 0.
* */
int btree_add_node (btree_t *t, int value);

/* Remove a value from the tree
* return 1 if successful otherwise 0.
* */
int btree_remove_node (btree_t *t, int value);

/* Look up a value in the tree
* return 1 if found otherwise 0.
* */
int btree_search (btree_t *t, int value);

Deadline

  • Saturday 24th Oct. 23:00

Submission

Submit just a zip file, containing 2 C files, in LMS. The file should be named as [9752xxxx.zip]. For example 97521234.zip.