<p>给定各个矩阵的大小,再给定他们的一个有着确定运算顺序的算式,判断他们能否正确地进行运算,如果可以进行正确的运算,求算出所需进行的乘法的次数,运算规则为线性代数里面的矩阵乘法法则。</p><div>源代码:</div>
</pre><pre name="code" class="html">#include<iostream>
#include<cstring>
#include<stack>
using namespace std;
int main()
{ int a[26][2],n,i,b3,b4,b5,b6,js[26][2];
char ch,c[100],x1,x2,js1='a';
long long int sum;
bool k1=true;
cin>>n;
while(n--)
{cin>>ch;
cin>>a[ch-'A'][0]>>a[ch-'A'][1];
}
while(cin>>c)
{stack <char> sta;
k1=true;
sum=0;js1='a';
for(i=0;c[i]&&k1;i++)
{if(c[i]<='Z'&&c[i]>='A')
sta.push(c[i]);
else if(c[i]==')'&&!sta.empty())
{ x1=sta.top();
sta.pop();
if(sta.empty()) sta.push(x1);
else {x2=sta.top();