using namespace std;
template
class vector
{protected:
H *T,l1[30];
int len;
public:
vector(H l)
{
len=l;
}
vector(H*c,H l)
{
len=l;
T=new H[len];
for(int i=0;i
}
void input_vec()
{
for(int i=0;i
cin>>l1[i];
}T=l1;
}
template
friend vector
template
friend vector
void output()
{
for(int i=0;i
cout<
cout<
};
template
vector
{
H size=A.len;
H*T=new H[size];
for(int i=0;i
T[i]=A.l1[i]+B.l1[i];
}return vector
}
template
vector
{
H size=A.len;
H*T=new H[size];
for(int i=0;i
T[i]=A.l1[i]-B.l1[i];
}return vector
}
template
class T_Matrix : public vector
{
public:
int line;
vector
T_Matrix(int a,int b); void input();
void output();
};
template
{
line=a;
}
template
{
for(int i=0;i
v1
}p=v1
}
template
{
for(int i=0;i
p[i]->output();
cout<
}
template
void culculate(T_Matrix
{
T_Matrix
p1->p=new vector
switch(ch)
{case '+':{
for(int i=0;i
p1->p[i]=a.v1
}
}break;
case '-':{
for(int i=0;i
p1->p[i]=a::v1
}
}break;
};
p1
};
int main()
{
int len,line1;
char ch;
while(cin>>ch>>line1>>len)
{
T_Matrix
first.input();
second.input();
culculate(first,second,line1,len,ch);
}
}
输出例子:
Sample Input
+2 3
1 2 3
4 5 6
1 2 3
4 5 6
-
2 3
1 2 3
4 5 6
7 8 9
10 11 12
Sample Output
2 4 68 10 12
-6 -6 -6
-6 -6 -6