主题:求助~~~~
想要求出多项式的加减,现在已经完成咯对多项式的输入和显示,
但是不知道怎么才能做到求加减,请求各位大人帮帮忙。谢谢~~~
十万火急,在线等;
代码如下;
#include<iostream.h>
const int MaxSize=10;
struct dxs
{
char xs[10];
char zs[10];
};
typedef dxs ElemType;
struct List
{
//ElemType List[MaxSize];
int size;
};
void main()
{
dxs g1,g2;
int n,m;
char op;
cout<<"输入几项式:"<<endl;
cin>>n;
cout<<"输入第一个数:"<<endl;
for(int i=1;i<=n;i++)
cin>>g1.xs[i]>>g1.zs[i];
for(int j=1;j<=n;j++)
cout<<"+"<<g1.xs[j]<<"x^"<<g1.zs[j];
cout<<endl;
cout<<"输入几项数"<<endl;
cin>>m;
cout<<"输入第2个式:"<<endl;
for(int a=1;a<=m;a++)
cin>>g2.xs[a]>>g2.zs[a];
for(int b=1;b<=m;b++)
cout<<"+"<<g2.xs[b]<<"x^"<<g2.zs[b];
cout<<endl;
cout<<"输入你的算法(+/-)"<<endl;
cin>>op;
switch(op)
{
case'+':
;
case'-':
;
}
}
帮忙改一下;
但是不知道怎么才能做到求加减,请求各位大人帮帮忙。谢谢~~~
十万火急,在线等;
代码如下;
#include<iostream.h>
const int MaxSize=10;
struct dxs
{
char xs[10];
char zs[10];
};
typedef dxs ElemType;
struct List
{
//ElemType List[MaxSize];
int size;
};
void main()
{
dxs g1,g2;
int n,m;
char op;
cout<<"输入几项式:"<<endl;
cin>>n;
cout<<"输入第一个数:"<<endl;
for(int i=1;i<=n;i++)
cin>>g1.xs[i]>>g1.zs[i];
for(int j=1;j<=n;j++)
cout<<"+"<<g1.xs[j]<<"x^"<<g1.zs[j];
cout<<endl;
cout<<"输入几项数"<<endl;
cin>>m;
cout<<"输入第2个式:"<<endl;
for(int a=1;a<=m;a++)
cin>>g2.xs[a]>>g2.zs[a];
for(int b=1;b<=m;b++)
cout<<"+"<<g2.xs[b]<<"x^"<<g2.zs[b];
cout<<endl;
cout<<"输入你的算法(+/-)"<<endl;
cin>>op;
switch(op)
{
case'+':
;
case'-':
;
}
}
帮忙改一下;