c语言程序设计题 题目:多项式计算

来源:百度知道 编辑:UC知道 时间:2024/05/17 03:41:23
题目:多项式计算
要求:
1主要功能:
(1)输入并建立多项式;
(2)输出多项式;
(3)两个多项式相加,建立并输出和多项式;
(4)两个多项式相减,建立并输出差多项式。
2.要求:一元多项式简单计算器的基本功能
求高人解答 谢谢

#define LEN sizeof(struct STD)
#define NULL 0
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
struct STD
{
int a;
int b;
struct STD *next;
};
int V;
struct STD *creat1(void)
{
FILE *fp;
struct STD *pN,*pT,*p;
struct STD *head=NULL;
pT=pN=(struct STD*)malloc(LEN);
fp=fopen("D:\\IN1.TXT","r");
if (fp==NULL)
{
printf("NULL\n");
return NULL;
}
while(!feof(fp))
{
fscanf(fp,"(%d,%d)",&pN->a,&pN->b);
/*if(pN->a!=0)
{ */
if (head==NULL) head=pN;
else pT->next=pN;
p=pT;
pT=pN;
pN=(struct STD*)malloc(LEN);
/*fscanf(fp,"(%d,%d)",&pN->a,&pN->b); */
}
if(head!=NULL)
p->next=NULL;
V=pT->b;
fclose(fp);
return head;
}
struct STD *creat2(void)