怎么从文件中读取两个多项式相乘后把结果输出到文件中
想从文件中读取两个多项式相乘后把结果输出到文件中感觉是代码有问题,调试时一直过不去,出现这句话“未使用调试信息生成二进制文件。”,是什么意思呢????代码哪里错了,求大神解救啊
#include "stdafx.h"
#include "stdlib.h"
#include "stdio.h"
typedef struct poly{
float coef;
int exp;
struct poly *next;
}poly;
void printpoly(FILE *fp){
float coef;
int exp;
while(!feof(fp)){
fscanf(fp,"%f %d,",&coef,&exp);
printf("%fx^%d,",coef,exp);
}
}
int com(int a,int b){
if(a==b)
return 0;
else
if(a<b)
return -1;
else
return 1;
}
poly *Creatpoly(FILE *fp){
poly *h,*p,*q;
h=(poly*)malloc(sizeof(poly));
h->next=NULL;
p=h;
while(!feof(fp)){
q=(poly*)malloc(sizeof(poly));
fscanf(fp,"%f %d,",&q->coef,&q->exp);
p->next=q;
p=q;
q->next=NULL;
}
return (h);
}
void printfy(poly *h){
int tag=1;
poly *p;
p=h->next;
while(tag){
tag=0;
if(p->next!=NULL){
printf("%f,%d",p->coef,p->exp);
p=p->next;
tag=1;
}
else printf("%f,%d",p->coef,p->exp);
}
}
poly *addpoly(poly *ha,poly *hb){
poly *qa,*qb,*p;
int a,b;
float m;
p=ha;
qa=ha->next;
qb=hb->next;
while(qa&&qb){
a=qa->exp;
b=qb->exp;
switch(com(a,b)){
case 0:
m=qa->coef+qb->coef;
if(m){
qa->coef=m;
p=qa;
}
else {
p->next=qa->next;
free(qa);
}
qa=p->next;
qb=qb->next;
break;
case -1:{
p=qa;qa=qa->next;
break; }
case 1:{
p->next=qb;
p=qb;
qb=qb->next;
p->next=qa;
break;
}
}
}
while(qb){
p->next=qb;
qb=qb->next;
}
return (ha);
}
void mulitpoly(poly *ha,poly *hb){
poly *p1,*p2,*q1,*q2,*e1,*e2;
p1=ha->next;
e1=(poly*)malloc(sizeof(poly));
e1->next=NULL;
e2=(poly*)malloc(sizeof(poly));
e2->next=NULL;
p2=e2;
while(p1!=NULL){
for(q1=hb->next;q1;q1=q1->next){
q2=(poly*)malloc(sizeof(poly));
q2->coef=p1->coef*q1->coef;
q2->exp=p1->exp+q1->exp;
p2->next=q2;
p2=q2;
q2->next=NULL;
}
p1=p1->next;
addpoly(e1,e2);
}
printf("the mulit jieguo is:\n");
printfy(e1);
}
void main(){
poly *ha,*hb;
FILE *fp,*fp1,*fp2;
fp=fopen("D:\\Documents\\Visual Studio 2010\\Projects\\poly.txt","r");
fp1=fopen("D:\\Documents\\Visual Studio 2010\\Projects\\poly1.txt","r");
fp2=fopen("D:\\Documents\\Visual Studio 2010\\Projects\\poly2.txt","w");
printf("the first poly is:\n");
printpoly(fp);
printf("the second poly is:\n");
printpoly(fp1);
printf("\n");
ha=Creatpoly(fp);
printfy(ha);
hb=Creatpoly(fp1);
printfy(hb);
printf("the mulit jieguo is:\n");
mulitpoly(ha,hb);
fclose(fp);
fclose(fp1);
fclose(fp2);
}