Question: Please complete the program to balance chemical equations. #include #include using namespace std; const int MAXELEM = 3 0 ; string names [ MAXELEM ]
Please complete the program to balance chemical equations.
#include
#include
using namespace std;
const int MAXELEM ;
string namesMAXELEM;
int nElem ;
long long linsysMAXELEMMAXELEM;
long long gcdlong long a long long b
if b
return a;
return gcdb ab;
int getIndexstring ename
forint i; i
coeffsindex val;
else
coeffsindex;
bool solvelong long aMAXELEMMAXELEM int n int m long long soln
solve linear system on n equations with m unknowns, checking
for unsolvable systems
if n m
return false;
forint i; i; i
long long val aim;
forint ji; j r p;
while r
icase;
nElem ;
forint i; i term;
forint j; j term;
forint j; j && i rp
factor gcdfactor solni;
i;
cout solnfactor;
forint i; i r p;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
