数据结构要求做个多项式计算器 用C语言 哪位高人有代码谢谢

来自:    更新日期:早些时候
高分跪求数据结构 一元多项式C语言代码~

下面是运行结果,需要的话给我个邮箱,发给你

/*
在vc++6.0中的输出结果:
------------------------
第一个一元多项式的非零项的个数m = 3
请依次输入3个系数和指数
1,2
5,4
3,3
第二个一元多项式的非零项的个数m = 3
请依次输入3个系数和指数
-3,3
4,2
7,1
这两个一元多项式相加的结果:
系数 指数
7.000000 1
5.000000 2
5.000000 4
请输入第三个一元多项式的非零项的个数m = 3
请依次输入3个系数和指数
-5,2
3,3
-3,1
多项式相加的结果(另外一种多项式相加的方法):
系数 指数
4.000000 1
3.000000 3
5.000000 4
请输入第四个一元多项式的非零项的个数m = 3
请依次输入3个系数和指数
4,1
2,3
6,6
两个多项式相减的结果:
系数 指数
1.000000 3
5.000000 4
-6.000000 6
请输入第五个一元多项式的非零项的个数m = 2
请依次输入2个系数和指数
1,1
2,2
两个多项式想乘的结果:
系数 指数
1.000000 4
7.000000 5
10.000000 6
-6.000000 7
-12.000000 8
销毁多项式
Press any key to continue

------------------------------
*/

大一上数据结构的时候写的:

#include
#include
#include
#include

typedef struct Item{
double coef;
int expn;
struct Item *next;
}Item,*Polyn;

#define CreateItem(p) p=(Item *)malloc(sizeof(Item));
#define DeleteItem(p) free((void *)p);
/************************************************************/
/*判断选择函数
*/
/************************************************************/
int Select(char *str)

{ char ch;
printf("%s
",str);
printf("Input Y or N:");
do{ ch=getch();
}while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n');
printf("
");
if(ch=='Y'||ch=='y') return(1);
else return(0);
}


/************************************************************/
/*插入位置定位函数 */
/**************************************************************/
int InsertLocate(Polyn h,int expn,Item **p)

{ Item *pre,*q;
pre=h;
q=h->next;
while(q&&q->expn<expn)


{ pre=q;
q=q->next;
}


if(!q)

{ *p=pre;
return(1);
}


else if(q->expn==expn)

{ *p=q;
return(0);
}


else
{ *p=pre;
return(-1);

}

}
/************************************************************/
/*插入结点函数
*/
/************************************************************/
void insert(Item *pre,Item *p)
{

p->next=pre->next;
pre->next=p;
}


/************************************************************/
/*输入多项式 */
/************************************************************/
Polyn Input(void)
{


double coef;
int expn,flag;
Item *h,*p,*q,*pp;
CreateItem(h);//产生头结点
h->next=NULL;
printf("input coef and expn(if end ,expn=-1)
");
while(1)
{


scanf("%lf%d",&coef,&expn); //输入多项式的系数和指数
if(expn==-1) break; //若指数为-1,表示输入结束
if(InsertLocate(h,expn,&pp))//返回值非 0表示插入新结点

{ CreateItem(p);
p->coef=coef;
p->expn=expn;
insert(pp,p);
}


else if(Select("has the same expn,Replace older value?"))
pp->coef=coef; //指数相同,替换系数


}
return h;
}


/************************************************************/
/*撤消多项式 */
/************************************************************/
void Destroy(Polyn h)
{


Item *p=h,*q;
while(p!=NULL)




{
q=p;
p=p->next;
DeleteItem(q);
}


}
/************************************************************/
/*输出多项式 */
/************************************************************/
void Output(Polyn h,char *title)
{

int flag=1;
Item *p=h->next;
printf("%s=",title);
while(p)
{ if(flag) //表示是否是多项式的第一项


{ flag=0;
if(p->expn==0) printf("%.2lf",p->coef);
else printf("%.2lfx^%d",p->coef,p->expn);
}


else

{ if(p->coef>0) printf("+");
if(p->expn==0) printf("%.2lf",p->coef);
else printf("%.2lfx^%d",p->coef,p->expn);
}


p=p->next;

}
printf("
");
}


/************************************************************/
/*判断两个多项式项的关系 */
/************************************************************/
int ItemComp(Item x,Item y)
{ if(x.expn<y.expn)


return(-1);
else if(x.expn==y.expn)


return(0);
else return(1);
}


/************************************************************/
/*两多项式多项式相加
*/
/************************************************************/
Polyn AddPolyn(Polyn h1,Polyn h2)

{
Item *head,*last,*pa=h1->next,*pb=h2->next,*s,*s0;
double coef;
CreateItem(head);
last=head;
head->next=NULL;
while(pa && pb)
{
switch(ItemComp(*pa,*pb))
{
case -1:
CreateItem(s);
*s=*pa;
pa=pa->next;
s->next=NULL;
break;
case 0:
coef=pa->coef+pb->coef;
if(coef!=0.0)
{
CreateItem(s);
s->coef=coef;
s->expn=pa->expn;
s->next=NULL;
}
pa=pa->next;
pb=pb->next;
break;
case 1:
CreateItem(s);
*s=*pb;
pb=pb->next;
s->next=NULL;
break;
}
if(head->next==NULL)
{
insert(head,s);
last=s;
}
else
{
insert(last,s);
last=s;
}

}
// last->next=pa?pa:pb;

//实现两个多项式相加运算的代码
//(由学生独立完成)

last->next=NULL;
return head;
}


/************************************************************/
/*两多项式多项式相减
*/
/************************************************************/
Polyn SubtractPolyn(Polyn h1,Polyn h2)
{ int flag;


Item *head,*last,*pa=h1->next,*pb=h2->next,*s,*s0;
double coef;
int a,b;
CreateItem(head);
last=head;
while(pa&&pb)
{
a=pa->expn;
b=pb->expn;
switch(ItemComp(*pa,*pb))
{
case -1:
CreateItem(s);
*s=*pa;
/* //insert(s,s0);
* //s=s->next;
*/
pa=pa->next;
s->next=NULL;
break;
case 0:
coef=pa->coef-pb->coef;

if(coef!=0.0)
{
CreateItem(s);
s->coef=coef;
s->expn=pa->expn;
/* //insert(s,s0); */
s->next=NULL;
/* //s=s->next; */
}
pa=pa->next;
pb=pb->next;
break;
case 1:
CreateItem(s);
*s=*pb;
s->coef=-1*s->coef;
/* //insert(s,s0);
* //s=s->next;
*/
pb=pb->next;
s->next=NULL;
break;
}
if(head->next==NULL)
{
insert(head,s);
last=s;
}
else
{
insert(last,s);
last=s;
}
}
if(pa)
last->next=pa;
else
{
last->next=pb;
while(pb)
{
pb->coef*=-1;
pb=pb->next;
}
}

//实现两个多项式相减运算的代码
//(由学生独立完成)

last->next=NULL;
return head;
}


/************************************************************/
/*两多项式多项式相乘
*/
/************************************************************/
Polyn MultPolyn(Polyn h1,Polyn h2) //两个多项式相乘
{ int item,expn;


Item *head,*pa,*pb=h2->next,*s,*pp;
double coef;
CreateItem(head);
head->next=NULL;
CreateItem(pp);
pp->next=NULL;
for(;pb;pb=pb->next)
{
for(pa=h1->next;pa;pa=pa->next)
{
CreateItem(s);
pp->next=s;
s->coef=pa->coef*pb->coef;
s->expn=pa->expn+pb->expn;
s->next=NULL;
head=AddPolyn(pp,head);

}
}

//实现两个多项式相乘运算的代码
//(由学生独立完成)

\f


return head;

}
/************************************************************/
/*菜单选择 */
/************************************************************/
int menu(void)

{ int num;
//clrscr();
printf("%20c1--create P(x)
",' ');
printf("%20c2--create Q(x)
",' ');
printf("%20c3--p(x)+Q(x)
",' ');
printf("%20c4--P(x)-Q(x)
",' ');
printf("%20c5--p(x)*Q(x)
",' ');
printf("%20c6--print P(x)
",' ');
printf("%20c7--print Q(x)
",' ');
printf("%20c8--print P(x)+Q(x)
",' ');
printf("%20c9--print P(x)-Q(x)
",' ');
printf("%20c10--print P(x)*Q(x)
",' ');
printf("%20c11--Quit
",' ');
printf(" please select 1,2,3,4,5,6,7,8,9,10,11:");


do{
scanf("%d",&num);
}while(num11);


return(num);

}
/************************************************************/
/*判断多项式是否存在 */
/************************************************************/
int PolynNotEmpty(Polyn h,char *p)

{ if(h==NULL)

{ printf("%s is not exist!
",p);
getchar();
return(0);
}


else return(1);

}
/************************************************************/
/*主函数 */
/************************************************************/
void main()
{ int num;

Polyn h1=NULL; //p(x)
Polyn h2=NULL; //Q(x)
Polyn h3=NULL; //P(x)+Q(x)
Polyn h4=NULL; //P(x)-Q(x)
Polyn h5=NULL; //P(x)*Q(x)
while(1)

{ num=menu();
getchar();
switch(num)


{
case 1: //输入第一个多项式,若多项式存在,首先撤消然后再输入
if(h1!=NULL)
{ if(Select("P(x) is not Empty,Create P(x) again?"))

{ Destroy(h1);
h1=Input();
}


}
else h1=Input();
break;
case 2: //输入第二个多项式,若多项式存在,首先撤消然后再输入
if(h2!=NULL)
{ if(Select("Q(x) is not Empty,Create Q(x) again?"))

{ Destroy(h2);
h2=Input();
}


}
else h2=Input();
break;


case 3: //两多项式相加
if(PolynNotEmpty(h1,"p(x)")&&PolynNotEmpty(h2,"Q(X)"))
{h3=AddPolyn(h1,h2);
Output(h3,"P(x)+Q(X)");
printf("P(x)+Q(x) has finished!
");
getchar();
}
break;
case 4: //两多项式相减
if(PolynNotEmpty(h1,"p(x)")&&PolynNotEmpty(h2,"Q(X)"))
{ h4=SubtractPolyn(h1,h2);
Output(h4,"Px)-Q(x)");

printf("P(x)-Q(x) has finished!
");
getchar();
}
break;


case 5: //两多项式相乘

if(PolynNotEmpty(h1,"p(x)")&&PolynNotEmpty(h2,"Q(X)"))
{ h5=MultPolyn(h1,h2);

Output(h5,"P(x)*Q(x)");
printf("P(x)*Q(x) has finished!
");
getchar();


}
break;
case 6: //显示第一个多项式
if(PolynNotEmpty(h1,"p(x)"))


{ Output(h1,"P(x)");
getchar();
}


break;
case 7: //显示第二个多项式
if(PolynNotEmpty(h2,"Q(x)"))

{ Output(h2,"Q(x)");
getchar();
}
break;


case 8: //显示相加结果多项式
if(PolynNotEmpty(h3,"P(x)+Q(x)"))

{ Output(h3,"P(x)+Q(x)");
getchar();
}
break;


case 9: //显示相减结果多项式
if(PolynNotEmpty(h4,"P(x)-Q(x)"))

{ Output(h3,"P(x)-Q(x)");
getchar();
}
break;


case 10: //显示相乘结果多项式
if(PolynNotEmpty(h5,"P(x)*Q(x)"))

{ Output(h3,"P(x)*Q(x)");
getchar();
}
break;


case 11: //结束程序运行。结束前应先撤消已存在的多项式
if(h1!=NULL) Destroy(h1);
if(h2!=NULL) Destroy(h2);
if(h3!=NULL) Destroy(h3);
if(h4!=NULL) Destroy(h4);
if(h4!=NULL) Destroy(h4);

\f
if(h4!=NULL) Destroy(h5);

}
if(num==11) break;
}
}

#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>

typedef struct _POLYNODE{
int coef;//系数
int exp;//指数
struct _POLYNODE *next;
}polynode,*polyptr;

void createPoly(polynode **P, char ch[]);//建立多项式链表
void polyAdd(polynode *A,polynode *B);//多项式加
void polyMinus(polynode *A,polynode *B);//减
void polyMulti(polynode *A,polynode *B);//乘
void polyDiv(polynode *A,polynode *B);//除
void order(polynode **P);//排序
void display(polynode *P);//展示多项式
void destroy(polynode **P);//销毁多项式
void menu();//命令菜单
int isPut(char ch[]);
//菜单
void menu(){
printf("1.输入多项式.\n"
"2.多项式相加.\n"
"3.多项式相减.\n"
"4.多项式相乘.\n"
"5.多项式相除.\n"
"6.显示多项式.\n"
"7.销毁多项式.\n"
"8.退出.\n");
}
//判断菜单选择
int IsChoice(int choice){
if(0 < choice && 9 > choice)
return 1;
else
return 0;
}

int isPut(char ch[]){
int i,j = 1;
for(i = 0; ch[i] != '\0'; i++){
{if(0 == j && '^' == ch[i])
return 0;
if('^' == ch[i] && 1 == j)
j = 0;
if(('+' ==ch[i] || '-' == ch[i] || '*' == ch[i] || '/' == ch[i]) && 0 == j)
j = 1;

}
if('x' != ch[i] && 'X' != ch[i] && '^' != ch[i] && '+' != ch[i] && '-' != ch[i] && '*' != ch[i] && '/' != ch[i] && !isdigit(ch[i]))
return 0;
else{
if('+' ==ch[0] || '*' == ch[0] || '/' == ch[0] || '^' == ch[0])
return 0;
if('\0' == ch[i+1] && '+' ==ch[0] || '*' == ch[0] || '/' == ch[0] || '^' == ch[0])
return 0;
// 上面是判断字符串首尾是否合格 下面是中间部分
if(0 != i && ch[i+1] != '\0' ){
if(('X' == ch[i] || 'x' == ch[i]) && !isdigit(ch[i-1]) && '+' != ch[i-1] && '-' != ch[i-1] && '*' != ch[i-1] && '/' != ch[i-1])
return 0;
if(('X' == ch[i] || 'x' == ch[i]) && '^' != ch[i+1] && '+' != ch[i+1] && '-' != ch[i+1] && '*' != ch[i+1] && '/' != ch[i+1])
return 0;
if(('+' == ch[i] || '-' == ch[i] || '*' == ch[i] || '/' == ch[i]) && !isdigit(ch[i-1]) && 'X' != ch[i-1] && 'x' != ch[i-1] && !isdigit(ch[i+1]) && 'X' != ch[i+1] && 'x' != ch[i+1])
return 0;
if('^' == ch[i] && 'X' != ch[i-1] && 'x' != ch[i-1])
return 0;
if('^' == ch[i] && !isdigit(ch[i+1]))
return 0;
}
}
}
return 1;
}

void createPoly(polynode **P, char ch[]){//写到这里
char *t = ch;
int i = 0, j = 1;
int iscoef = 1,isminus = 1;
polyptr Q,L;

if('-' == ch[0]){
isminus = -1;
*t++;
}
while('\0' != *t){
Q = (polyptr)malloc(sizeof(polynode));
Q->coef = 1;
Q->exp = 0;
Q->next = NULL;//申请节点,初始化参数为1.

if(-1 == isminus){
Q->coef *= isminus;
isminus = 1;
}

while('+' != *t && '-' != *t && '*' != *t && '/' != *t && '\0' != *t){
if('x' != *t && 'X' != *t){
while(isdigit(*t)){
i =((int)*t - 48) + i*10;
t++;
j *= i;
}//抽取数字
if(1 == iscoef && 0 != i){
Q->coef *= i;
}
if(0 == iscoef){
Q->exp += i;
iscoef = 1;
}
//如果i=0,则

}
else{
iscoef = 0;
t++;
if('^' == *t)
t++;
else
Q->exp = 1;
}
i = 0;
}//while 遍历到加减乘除,则退出循环,到下一新的节点
iscoef = 1;
if('\0' != *t){
if('-' == *t)
isminus = -1;
t++;
}
if(0 == j){
Q->coef = 0;
j = 1;
}
printf("系数:%d,指数:%d\n",Q->coef,Q->exp);

if(NULL == *P){
*P = Q;
}
else{
L->next = Q;
}
L = Q;

}//while遍历整个字符串

}
void polyAdd(polynode *A,polynode *B){
polyptr P = A, Q,L;
polyptr COPYA = NULL,COPYB = NULL;
if(NULL == A || NULL == B){
return ;
printf("多项式未被建立.\n");
}

while(NULL != P){//复制A
Q = (polyptr)malloc(sizeof(polynode));
Q->coef = P->coef;
Q->exp = P->exp;
Q->next = NULL;
if(NULL == COPYA)
COPYA = Q;
else
L->next = Q;
L = Q;
P = P->next;
}
P = B;
while(NULL != P){//复制B
Q = (polyptr)malloc(sizeof(polynode));
Q->coef = P->coef;
Q->exp = P->exp;
Q->next = NULL;
if(NULL == COPYB)
COPYB = Q;
else
L->next = Q;
L = Q;
P = P->next;
}

L->next = COPYA;//把COPYA,COPYB两个多项式连接起来,整理一下就OK了.
order(©B);
order(©B);
printf("相加结果为:");
display(COPYB);
destroy(©B);
}
void polyMinus(polynode *A,polynode *B){//相减和相加差不多
polyptr P = A, Q,L;
polyptr COPYA = NULL,COPYB = NULL;
if(NULL == A || NULL == B){
return ;
printf("多项式未被建立.\n");
}

while(NULL != P){//复制A
Q = (polyptr)malloc(sizeof(polynode));
Q->coef = P->coef;
Q->exp = P->exp;
Q->next = NULL;
if(NULL == COPYA)
COPYA = Q;
else
L->next = Q;
L = Q;
P = P->next;
}
P = B;
while(NULL != P){//复制B
Q = (polyptr)malloc(sizeof(polynode));
Q->coef = -(P->coef);
Q->exp = P->exp;
Q->next = NULL;
if(NULL == COPYB)
COPYB = Q;
else
L->next = Q;
L = Q;
P = P->next;
}

L->next = COPYA;//把COPYA,COPYB两个多项式连接起来,整理一下就OK了.
order(©B);
order(©B);
printf("相减结果为:");
display(COPYB);
destroy(©B);

}
void polyMulti(polynode *A,polynode *B){}
void polyDiv(polynode *A,polynode *B){}

void display(polynode *P){
//考虑情况有系数为1,指数为1,0,一般数;系数为系数不为1,指数为1,0,一般数;
//系数为负数,指数为1,0,一般数,主要考虑中间符号问题.
if(NULL == P){
printf("多项式为空.\n");
return ;
}
if(1 == P->coef){
if(0 == P->exp)
printf("1");
else if(1 == P->exp) printf("x");
else printf("x^%d",P->exp);
}
else{
if(0 == P->exp)
printf("%d",P->coef);
else if(1 == P->exp) printf("%dx",P->coef);
else
printf("%dx^%d",P->coef,P->exp);
}
P = P->next;
while(NULL != P){
if(0 < P->coef){
if(1 == P->coef){
if(0 == P->exp)
printf("+1");
else if(1 == P->exp) printf("+x");
else printf("+x^%d",P->exp);
}
else{
if(0 == P->exp)
printf("+%d",P->coef);
else if(1 == P->exp) printf("+%dx",P->coef);
else
printf("+%dx^%d",P->coef,P->exp);
}
}
else{
if(-1 == P->coef){
if(0 == P->exp)
printf("-1");
else if(1 == P->exp) printf("-x");
else printf("-x^%d",P->exp);
}
else{
if(0 == P->exp)
printf("%d",P->coef);
else if(1 == P->exp) printf("%dx",P->coef);
else
printf("%dx^%d",P->coef,P->exp);
}
}
P = P->next;
}
printf("\n");
}

void destroy(polynode **P){
polyptr Q = *P;
if(NULL == *P)
return ;
while(*P != NULL){
Q = *P;
*P = (*P)->next;
delete Q;
}

}

void order(polynode **P){
//首先 系数为零的要清掉,其次指数从高到低排序,再者系数相同的要合并.
polyptr prev,curr,OUT,INcurr;//前一节点和当前节点
int temp;

//出去第一节点系数为0的项
while(NULL != *P){
if(0 != (*P)->coef)
break;
else{
if(NULL == (*P)->next)
return;
curr = *P;
(*P) = (*P)->next;
delete curr;
}
}
if(NULL == *P || NULL == (*P)->next)//如果只剩1项或空,则不需要整理,退出函数
return;
//冒泡排序
OUT = INcurr = *P;
while(NULL != OUT->next){//外循环
while(NULL != INcurr->next){//内循环
prev = INcurr;
INcurr = INcurr->next;
if(prev->exp < INcurr->exp){
temp = prev->coef;
prev->coef = INcurr->coef;
INcurr->coef = temp;//交换系数

temp = prev->exp;
prev->exp = INcurr->exp;
INcurr->exp = temp;//交换指数
}
}
OUT = OUT->next;
INcurr = *P;
}

//去除0项
prev = curr = *P;
curr = curr->next;
while(NULL != curr){
if(0 == curr->coef){
prev->next = curr->next;
delete curr;
curr = prev->next;
}
else{
prev = curr;
curr = curr->next;
}
}
//合并同类项
OUT = INcurr = *P;
while(NULL != OUT->next){
while(NULL != INcurr->next){
prev = INcurr;
INcurr = INcurr->next;
if(INcurr->exp == OUT->exp){
OUT->coef += INcurr->coef;
prev->next = INcurr->next;
delete INcurr;
INcurr = prev;
}
}
INcurr = OUT = OUT->next;
if(NULL == OUT)
return;
}

}

void main(){
int choice;
// int i;
char ch[100];
polynode *polyA,*polyB;

polyA = polyB = NULL;

menu();
scanf("%d",&choice);
while(!IsChoice(choice)){
menu();
printf("输入错误,重新输入.\n");
scanf("%d",&choice);
}
while(8 != choice){
switch(choice){
case 1:
if(NULL != polyA || NULL != polyB){
destroy(&polyA);
destroy(&polyB);
printf("原多项式被销毁.\n");
}
printf("输入多项式A:\n");
scanf("%s",&ch);

while(!isPut(ch)){
printf("输入错误!重新输.\n");
scanf("%s",&ch);
}
createPoly(&polyA,ch);//建立多项式A链表

printf("输入多项式B:\n");
scanf("%s",&ch);
while(!isPut(ch)){
printf("输入错误!重新输.\n");
scanf("%s",&ch);
}
createPoly(&polyB,ch);//建立多项式B链表
order(&polyB);
order(&polyA);//整理排序多项式

printf("建立多项式成功!多项式:\nA为:");
display(polyA);
printf("B为:");
display(polyB);
break;
case 2:
polyAdd(polyA,polyB);
break;
case 3:
polyMinus(polyA,polyB);
break;
case 4:
polyMulti(polyA,polyB);
break;
case 5:
polyDiv(polyA,polyB);
break;
case 6:
printf("------显示多项式------\nA :");
display(polyA);
printf("B :");
display(polyB);
break;
case 7:
destroy(&polyA);
destroy(&polyB);
printf("此多项式已被清空.\n");
break;
default:
return ;
}
choice = 0;
menu();
scanf("%d",&choice);
while(!IsChoice(choice) || 0 == choice){
menu();
printf("输入错误,重新输入.\n");
scanf("%d",&choice);
}
}
}

目前还没开 乘除功能。
对了 输入形式为:2x^2+3x^4-2x^9
按这种形式输入就可以了,输其他的会提示错误

中间有些©这个符号 不知道为什么这个显示 其实是&符号

我做了一个 但是没做完 就差除法。。
不过这个东西很难写,我以前写过的 写了1000多行,最近重新写一个。。

需要hi我 ,


数据结构要求做个多项式计算器 用C语言 哪位高人有代码谢谢视频

相关评论:
  • 18680241364运用C#数据结构编写程序进行一元多项式的计算
    贝谢勤虽然效率不怎么样反正是可以用 using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class Polynomial { class RankFactorMap { public int rank_; public double factor_; } List<RankFactorMap> data_; public...

  • 18680241364数据结构课程设计报告(一元多项式的计算)
    贝谢勤【问题描述】编程实现一元多项式的加法计算。【基本要求】能用链表实现一元多项式的加法计算,并能打印出计算结果。【所需知识】(1)基本编程方法和程序设计知识。(2)链表的理解和运算与运用。【所用算法】遍历算法和递归算法。【操作平台】Visual C++ include<stdio.h> include<graphics.h> define MAX...

  • 18680241364用C语言做一个计算器,能实现加减乘除混合运算?
    贝谢勤是的,可以使用C语言编写一个计算器程序,能够实现加、减、乘、除等混合运算。下面是一个简单的示例程序:```c include <stdio.h> int main() { char operator;double num1, num2, result;printf("Enter an operator (+, -, *, \/): ");scanf("%c", &operator);printf("Enter two ...

  • 18680241364数据结构的二元多项式计算
    贝谢勤operator >> (istream& in, Polynomal& x){ Term *rear = x.first;float c;int e,a;int size=0;cout<<"请输入多项式的项数:"<<endl;cin>>a;while (size<a){ cout << "Input a term(coef, exp)(多项式按升序排列):" << endl;in >> c >> e;if ( size>a) break;...

  • 18680241364计算一元稀疏多项式
    贝谢勤输入说明:一组输入数据,所有数据均为整数。第1行为2个正整数n,m,其中 n表示第一个多项式的项数,m表示第二个多项式的项数。第2行包含2n个整数,每两个整数分别表示第一个多项式每一项的系数和指数;第3行包含2m个整数,每两个整数分别表示第二个多项式每一项的系数和指数。(注:序列按指数升序...

  • 18680241364数据结构(c++)一元多项式的代数运算
    贝谢勤2011-01-04 一元多项式计算器(《数据结构》,请用C++语言) 2015-01-30 求一个c++数据结构一元多项式的表示及相加的代码,要包括删除... 5 2013-04-21 一元多项式简单的计算器(数据结构C++)。 只求大神写下减法... 1 2009-08-02 数据结构一元多项式的代数运算 7 2016-10-04 用C++数据结构编程:一元多...

  • 18680241364使用链表完成一个整数计算器,该计算器需包含整数的加法、减法、乘法功...
    贝谢勤单元多项式的节点结构类型是这种:typedef struct node { float coef; \/\/系数 int expn; \/\/指数 struct node *next;}PolyNode; \/\/多项式节点 polynomial node 多项式的加法我们提供了两种:1.Polynomial polyAdd(Polynomial poly1, Polynomial poly2),把poly1和poly2相加得到一个新的多项式。

  • 18680241364数据结构 多项式合并
    贝谢勤链表中的系数相加。。指数不变。然后改下前后之间的指针。然后删除其中一个就OK了。。不能是加上去的那个

  • 18680241364C#怎样做计算器
    贝谢勤看看数据结构,有从根本上解决问题的方法,就是运算符优先法,先建立运算符优先表,括号也可以当成运算符来处理,键两个栈,运算符栈,和操作数栈,通过运算符优先级的比较进行入栈和出栈, 括号的匹配等等

  • 18680241364...可以进行加减乘除整数运算混合运算的计算器,要求写思路,越详细越好...
    贝谢勤通过实习,了解并初步掌握设计、实现较大系统的完整过程,包括系统分析、编码设计、系统集成、以及调试分析,熟练掌握数据结构的选择、设计、实现以及操作方法,为进一步的应用开发打好基础。 二.问题描述 在以二叉树表示算术表达式的基础上,设计一个十进制的四则运算的计算器。[设计要求]实现整数浮点数的四则运算。 三....

  • 相关主题精彩

    版权声明:本网站为非赢利性站点,内容来自于网络投稿和网络,若有相关事宜,请联系管理员

    Copyright © 喜物网