Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void division(list l1, list l2, list *p_quotient, list *p_reste)
- {
- list quotient_tmp = NULL;
- list diviseur_tmp = NULL;
- list top_l1 = l1, top_l2 = l2, top_p_reste = *p_reste;
- list node = NULL;
- int i;
- int lenght;
- while(top_l1){
- addNewList(p_reste,top_l1->monomial);
- top_l1 = top_l1->next;
- }
- topl_l1 = l1;
- while(top_l1->next) top_l1 = top_l1->next;
- while(top_l1->next) top_l1 = top_l1->next;
- int degree_dividende = top_l1->monomial.degree;
- int degree_diviseur = top_l2->monomial.degree;
- int degree_p_reste = top_l1->monomial.degree;
- if(top_l1->monomial.degree < top_l2->monomial.degree) {
- printf("erreur, degré du dividende < degré du diviseur");
- return;
- }
- do {
- quotient_tmp = (list) malloc(sizeof(listNode));
- quotient_tmp->next = NULL;
- quotient_tmp->monomial.degree = degree_dividende-degree_diviseur;
- quotient_tmp->monomial.coef = divide(top_l1->monomial.coef,top_l2->monomial.coef);
- multiply_polynomial(quotient_tmp,l2,&diviseur_tmp);
- lenght = lenght_list(*p_reste);
- substraction_polynomial(*p_reste,diviseur_tmp,p_reste);
- for ( i = 0 ; i < lenght ; i++ ) {
- node = *p_reste;
- free(node);
- node = node->next;
- }
- addNewList(p_quotient,quotient_tmp->monomial);
- while(top_p_reste->next) top_p_reste = top_p_reste->next;
- degree_p_reste = top_p_reste->monomial.degree;
- top_p_reste = *p_reste;
- freeList("ient_tmp);
- } while(degree_reste >= degree_dividende);
- freeList(&diviseur_tmp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement