c语言 多项式求导下面是我的代码 可DEV C++编译通过 但运行出错 请大侠们帮帮 #include #include typedef struct polynode { int conf;/*常数*/ int exp;/*指数*/ struct polynode *next; }polynode; int main() { polynode *p,*q,
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/05 23:05:17
![c语言 多项式求导下面是我的代码 可DEV C++编译通过 但运行出错 请大侠们帮帮 #include #include typedef struct polynode { int conf;/*常数*/ int exp;/*指数*/ struct polynode *next; }polynode; int main() { polynode *p,*q,](/uploads/image/z/9460390-22-0.jpg?t=c%E8%AF%AD%E8%A8%80+%E5%A4%9A%E9%A1%B9%E5%BC%8F%E6%B1%82%E5%AF%BC%E4%B8%8B%E9%9D%A2%E6%98%AF%E6%88%91%E7%9A%84%E4%BB%A3%E7%A0%81+%E5%8F%AFDEV+C%2B%2B%E7%BC%96%E8%AF%91%E9%80%9A%E8%BF%87+%E4%BD%86%E8%BF%90%E8%A1%8C%E5%87%BA%E9%94%99+%E8%AF%B7%E5%A4%A7%E4%BE%A0%E4%BB%AC%E5%B8%AE%E5%B8%AE+%23include+%23include+typedef+struct+polynode+%7B+int+conf%3B%2F%2A%E5%B8%B8%E6%95%B0%2A%2F++int+exp%3B%2F%2A%E6%8C%87%E6%95%B0%2A%2F++struct+polynode+%2Anext%3B+%7Dpolynode%3B+int+main%28%29+%7B+polynode+%2Ap%2C%2Aq%2C)
c语言 多项式求导下面是我的代码 可DEV C++编译通过 但运行出错 请大侠们帮帮 #include #include typedef struct polynode { int conf;/*常数*/ int exp;/*指数*/ struct polynode *next; }polynode; int main() { polynode *p,*q,
c语言 多项式求导
下面是我的代码 可DEV C++编译通过 但运行出错 请大侠们帮帮 #include #include typedef struct polynode { int conf;/*常数*/ int exp;/*指数*/ struct polynode *next; }polynode; int main() { polynode *p,*q,*h; /*建立多项式*/ int conf,exp; h=(polynode*)malloc(sizeof(polynode)); q=h; scanf("%d %d",&conf,&exp); while(conf!=-1||exp!=-1) { p=(polynode*)malloc(sizeof(polynode)); p->conf=conf; p->exp=exp; q->next=p; q=p; scanf("%d %d",&conf,&exp); } q->next=NUll; q=h; while(q->next!=NULL) /*求导*/ { q=q->next; if(q->exp>=1) { q->conf=(q->conf)*(q->exp); q->exp-=1; } else if(q->exp==0) { q=NULL; } else { printf("error"); break; } } q=h; while(q->next!=NULL)/*输出*/ { q=q->next; printf("%d %d",q->conf,q->exp); } return 0; }
c语言 多项式求导下面是我的代码 可DEV C++编译通过 但运行出错 请大侠们帮帮 #include #include typedef struct polynode { int conf;/*常数*/ int exp;/*指数*/ struct polynode *next; }polynode; int main() { polynode *p,*q,
#include #include typedef struct polynode { int conf;/*常数*/ int exp;/*指数*/ struct polynode *next; }polynode; int main() { polynode *p,*q,*h; /*建立多项式*/ int conf,exp; h=(polynode*)malloc(sizeof(polynode)); q=h; scanf("%d %d",&conf,&exp); while(conf!=-1||exp!=-1) { p=(polynode*)malloc(sizeof(polynode)); p->conf=conf; p->exp=exp; q->next=p; q=p; scanf("%d %d",&conf,&exp); } q->next=NULL; \\你是这里写错了,写成NUll了 q=h; while(q->next!=NULL) /*求导*/ { q=q->next; if(q->exp>=1) { q->conf=(q->conf)*(q->exp); q->exp-=1; } else if(q->exp==0) { q=NULL; } else { printf("error"); break; } } q=h; while(q->next!=NULL)/*输出*/ { q=q->next; printf("%d %d",q->conf,q->exp); } return 0; } 改成这样就能运行了