一元稀疏多项式的解决办法?

hechaonan 2003-04-05 10:10:44
要求用单链表解决。
...全文
38 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
skyling2001 2003-04-06
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <malloc.h>
#include <string.h>

typedef struct pnode
{
float coef;
int exp;
struct pnode *next;
}polynode;

polynode *creatnode()
{
float newcoef;
int newexp,k=0,h;

polynode *head,*s,*rear;
head=(struct pnode *)malloc(sizeof(polynode));

rear=head;
printf("length=");
scanf("%d",&h);

k=0;
while(k<h)
{
printf("xishu",k+1);
scanf("%f",&newcoef);
printf("zhishu",k+1);
scanf("%d",&newexp);
s=(struct pnode *)malloc(sizeof(polynode));
s->coef=newcoef;
s->exp=newexp;
// printf("%s->",s->coef);
rear->next=s;
rear=s;
printf("***************************************\n");

k++;
}
// printf("%d\n",&rear);
rear->next=head;
// printf("%d\n",&rear->next);
return (head);
}
然后在main中调用
azuretttc 2003-04-06
  • 打赏
  • 举报
回复
struct node
{int exp;
int ceof;
struct node * link;
};
typedef struct node NODE;
cutestar 2003-04-06
  • 打赏
  • 举报
回复
本人前几天才做完有关单链表和双链表的练习。自己做一做就知道了!!!

UP AND DOWN
yatuor 2003-04-05
  • 打赏
  • 举报
回复
本来就是应该用单链表解决的,节点中包括系数,次数就行了.

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧