Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started