带列表的多项式的操作

时间:2018-11-12 08:11:08

标签: c

这是我的功能和结构,不起作用的是 精确点void Derivee的导数和值, float Valeur。我当然会处理列表。

get_at(polyliste* p, int index ,float* coeff,int* deg)

typedef struct node* Node;
typedef struct node
{
    float coeff;
    int degree;
    Node next;
} node;

typedef struct
{
    Node head;
} polyliste;

polyliste create()
{
    polyliste p;
    p.head = NULL;
    return p;
}
float Valeur(polyliste p, float x)
{

    float s = 0, coeff;
    int i = 0, degree;

    while (get_at(&p, i, &coeff, &degree) == 0)
    {
        s = s + (coeff * power(x, degree));
        i++;
    }
    printf("\nLe resultat est : %f", s);
    return s;
}

void Derivee(polyliste *p, polyliste *s)
{
    int i = 0, degree;
    float coeff;
    *s = create();

    while (get_at(&p, i, &coeff, &degree) == 0)
    {
        if ((coeff != 0) && (degree != 0))
        {
            coeff *= degree;
            degree--;
            add_first(s, degree, coeff);
        }
        i++;
    }
}

0 个答案:

没有答案