Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* cette structure est utilisée dans la foncton d'affichage du resultat de la division euclidienne Affichage_diveucli */
- typedef struct
- {
- Poly quotient;
- Poly reste;
- } QuotientReste ;
- /* Division_Euclidienne fait la division euclidienne de deux polynomes et retourne le resultat sous forme de quotient et reste */
- QuotientReste Division_Euclidienne (Poly p1, Poly p2)
- {
- tidy_poly(p1);
- tidy_poly(p2);
- Poly Q,quotient_final,R,reste_final;
- Q = malloc (sizeof (struct p_data));
- R = malloc (sizeof (struct p_data));
- R->deg= p2->deg ;
- if (p1->deg >= p2->deg)
- {
- while (R->deg >= p2->deg)
- {
- Q->deg = p1->deg - p2->deg ;
- Q->coef = (p1->coef)/(p2->coef);
- R = poly_sub (p1,poly_mult(Q,p2)) ;
- Q=Q->red;
- printf("bla");
- Q = Division_Euclidienne(R,p2).quotient;
- R = Division_Euclidienne(R,p2).reste;
- }
- }
- quotient_final = Q ;
- reste_final = R ;
- tidy_poly(quotient_final);
- tidy_poly(reste_final);
- QuotientReste resultat;
- resultat.reste = reste_final ;
- resultat.quotient = quotient_final;
- //printf( "Le quotient est:");
- //print_poly(quotient_final);
- //printf("\n.Le reste est:");
- //print_poly(reste_final);
- return (resultat) ;
- }
Add Comment
Please, Sign In to add comment