易语言全P源码怎么制作成全P摸版呢
答案:1 悬赏:10 手机版
解决时间 2021-08-11 22:21
- 提问者网友:嘚啵嘚啵
- 2021-08-11 01:18
缺少1.8.0的全P摸版 但是找到了1.8.0的全P源码请高手指点
最佳答案
- 五星知识达人网友:孤老序
- 2021-08-11 02:15
这是我亲自写的,没有按照你定义的结构体和函数名来写,已经实现创建,相加,相乘,输出了,插入的话你自己完成吧
输入方法:
1 2 1 1 0 0
1 2 1 1 0 0
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef struct polynomial
{
int coef,ex;
struct polynomial *next;
}POLY;
POLY *create_poly(void);
POLY *add_poly(POLY *,POLY *);
POLY *mul_poly(POLY *,POLY *);
void print_poly(POLY *);
int main(void)
{
POLY *heada=NULL,*headb=NULL,*headsum=NULL,*headmul=NULL;
printf("create the first multinomial:\n");
heada=create_poly();
printf("create the second multinomial:\n");
headb=create_poly();
printf("The first multinomial:\n");
print_poly(heada);
printf("The second multinomial:\n");
print_poly(headb);
headsum=add_poly(heada,headb);
printf("The sum multinomial:");
print_poly(headsum);
headmul=mul_poly(heada, headb);
printf("The mul multinomial:");
print_poly(headmul);
return 0;
}
//创建
POLY *create_poly()
{
int iA=0,iE=0;
POLY *head=NULL,*s=NULL,*r=NULL;
head=(POLY *)malloc(sizeof(POLY));
r=head;
printf("please input coef and exponent:\n");
scanf("%d%d",&iA,&iE);
while(iA != 0)
{
s=(POLY *)malloc(sizeof(POLY));
s->coef=iA,s->ex=iE;
r->next=s;
r=s;
scanf("%d%d",&iA,&iE);
}
r->next=NULL;
return head;
}
//相加
POLY *add_poly(POLY *p1, POLY *p2) //多项式相加
{
POLY *head, *tmp, *s;
int value;
p1=p1->next;
p2=p2->next;
head=tmp=(POLY*)malloc(sizeof(POLY));
head->next=NULL;
while(p1 && p2)
{
if(p1->ex == p2->ex)
{
value=p1->coef+p2->coef;
if(value != 0)
{
s=(POLY *)malloc(sizeof(POLY));
s->coef=value;
s->ex=p1->ex;
s->next=NULL;
输入方法:
1 2 1 1 0 0
1 2 1 1 0 0
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef struct polynomial
{
int coef,ex;
struct polynomial *next;
}POLY;
POLY *create_poly(void);
POLY *add_poly(POLY *,POLY *);
POLY *mul_poly(POLY *,POLY *);
void print_poly(POLY *);
int main(void)
{
POLY *heada=NULL,*headb=NULL,*headsum=NULL,*headmul=NULL;
printf("create the first multinomial:\n");
heada=create_poly();
printf("create the second multinomial:\n");
headb=create_poly();
printf("The first multinomial:\n");
print_poly(heada);
printf("The second multinomial:\n");
print_poly(headb);
headsum=add_poly(heada,headb);
printf("The sum multinomial:");
print_poly(headsum);
headmul=mul_poly(heada, headb);
printf("The mul multinomial:");
print_poly(headmul);
return 0;
}
//创建
POLY *create_poly()
{
int iA=0,iE=0;
POLY *head=NULL,*s=NULL,*r=NULL;
head=(POLY *)malloc(sizeof(POLY));
r=head;
printf("please input coef and exponent:\n");
scanf("%d%d",&iA,&iE);
while(iA != 0)
{
s=(POLY *)malloc(sizeof(POLY));
s->coef=iA,s->ex=iE;
r->next=s;
r=s;
scanf("%d%d",&iA,&iE);
}
r->next=NULL;
return head;
}
//相加
POLY *add_poly(POLY *p1, POLY *p2) //多项式相加
{
POLY *head, *tmp, *s;
int value;
p1=p1->next;
p2=p2->next;
head=tmp=(POLY*)malloc(sizeof(POLY));
head->next=NULL;
while(p1 && p2)
{
if(p1->ex == p2->ex)
{
value=p1->coef+p2->coef;
if(value != 0)
{
s=(POLY *)malloc(sizeof(POLY));
s->coef=value;
s->ex=p1->ex;
s->next=NULL;
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯