91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

使用鏈表實(shí)現(xiàn)多項(xiàng)式的加法和乘法,數(shù)據(jù)結(jié)構(gòu)常見問題的C語言實(shí)現(xiàn)

資源截圖

代碼片段和文件信息

#include
#include
#include
typedef?struct?list
{
????int?xishu;
????int?power;
????struct?list?*next;
}list;

list*?creat()
{
????list*?head=(list*)malloc(sizeof(list));
????if(head==NULL)
????{
????????printf(“malloc?head?node?failed\n“);
????????exit(-1);
????}
????head->xishu=0;
????head->power=0;
????head->next=NULL;
????int?count;
????printf(“please?input?the?count?of?the?list:“);
????scanf(“%d“&count);
????printf(“please?input?%d?xiangwith?the?power?increase\n“count);
????while(count<=0)
????{
????????printf(“the?input?is?invalidplease?input?the?count?of?the?list?again:“);
????????scanf(“%d“&count);
????}
????while(count>0)
????{
????????list?*newnode=(list*)malloc(sizeof(list));
????????if(newnode==NULL)
????????{
????????????printf(“malloc?newnode?failed\n“);
????????????exit(-1);
????????}
????????printf(“please?input?xishu:“);
????????scanf(“%d“&newnode->xishu);
????????printf(“please?input?power:“);
????????scanf(“%d“&newnode->power);
????????newnode->next=head->next;
????????head->next=newnode;
????????--count;
????}
????return?head;
}

void?print(const?list*?lst)
{
????if(lst==NULL)
????????printf(“the?list?is?not?exist\n“);
????if(lst->next!=NULL)
????{
????????list?*p=lst->next;
????????while(p!=NULL)
????????{
????????????if(p->power!=0&&p->xishu!=1&&p->power!=1)
????????????????printf(“%dX^%d“p->xishup->power);
????????????else?if(p->power!=0&&p->xishu!=1&&p->power==1)
????????????????printf(“%dX“p->xishu);
????????????else?if(p->power!=0&&p->xishu==1&&p->power!=1)
????????????????printf(“X^%d“p->power);
????????????else?if(p->power==1&&p->xishu==1)
????????????????printf(“X“);
????????????else
????????????????printf(“%d“p->xishu);
????????????p=p->next;
????????????if(p!=NULL)
????????????????printf(“+“);
????????}
????????printf(“\n“);
????}

}

void?list_free(list?*a)
{
????if(a==NULL)
????????return?;
????list?*pa=a->next;
????while(pa!=NULL)
????{
????????list?*tmp=pa;
????????pa=pa->next;
????????free(tmp);
????????tmp=NULL;
????}
????free(a);
????a=NULL;
}

list?*list_copy(const?list?*src)
{
????if(src==NULL)
????{
????????printf(“the?list?is?not?exist\n“);
????????exit(-1);
????}
????const?list?*p=src->next;
????list*?head=(list*)malloc(sizeof(list));
????if(head==NULL)
????{
????????printf(“malloc?head?node?failed\n“);
????????exit(-1);
????}
????head->xishu=0;
????head->power=0;
????head->next=NULL;
????list*?place=head;
????while(p!=NULL)
????{
????????list?*newnode=(list*)malloc(sizeof(list));
????????if(newnode==NULL)
????????{
????????????printf(“malloc?newnode?failed\n“);
????????????exit(-1);
????????}
????????newnode->xishu=p->xishu;
????????newnode->power=p->power;

????????

評(píng)論

共有 條評(píng)論

相關(guān)資源