I wanted to simplify algebraic expressions in c++. I started with something simple: removing brackets from a algebraic expression containing + and – operators. For example, a-(b-c) should be simplified to a-b+c. This link gives the answer to this question. Here is the source code: #include <iostream> #include <string.h> #include <stack> using namespace std; // ..
Category : algebra
I would like to simplify basic algebraic expressions such as (x + 2y * (3x + 2)) / 5. Are there any libraries that exist in C++ that allow me to do so? Source: Windows Que..
I have this code for compressing data. First, I collect the last 3 on bits of a byte. Then I record the rest. Using a simple algorithm, I strip the differences of their lengths. This is seen in the code just below. int cx_lo_bits = (j > -1) ? j : -1; int cx_mid_bits = ..
I need function to fast compare root of quadratic function and a given value and function to fast compare two roots of two quadratic functions. I write first function bool isRootLessThanValue (bool sqrtDeltaSign, int a, int b, int c, int value) { bool ret; if(sqrtDeltaSign){ if(a < 0){ ret = (2*a*value + b < 0) ..
I’ve found an exercise in which I am supposed to calculate the factorial of all numbers in a vector. The exercise goes as follows. You are given "n" natural numbers. Calculate the product of their factorials modulo 1.000.000.007 Constraints are as follows: 1 <= n <= 1e+6 All the numbers/elements are less than 1e+7. I’ve ..
Recent Comments