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));
- quotient_final = NULL;
- quotient_final = Q ;
- R = malloc (sizeof (struct p_data));
- reste_final = R ;
- R->deg= 99 ;
- QuotientReste resultat;
- resultat.reste = reste_final ;
- resultat.quotient = quotient_final;
- while (R->deg >= p2->deg)
- {
- if (p1->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");
- R = Division_Euclidienne(R,p2).reste;
- Q = Division_Euclidienne(R,p2).quotient;
- }
- break;
- }
- tidy_poly(quotient_final);
- tidy_poly(reste_final);
- //printf( "Le quotient est:");
- //print_poly(quotient_final);
- //printf("\n.Le reste est:");
- //print_poly(reste_final);
- return (resultat) ;
- }
- /* affichage_diveucli prend en parametre le resultat de la division euclidienne de deux polynomes et affiche le reste et le quotient */
- void Affichage_diveucli ( QuotientReste q )
- {
- Poly reste1,quotient1;
- reste1 = q.reste;
- quotient1 = q.quotient;
- printf ("Le quotient est :");
- print_poly(quotient1);
- printf ("\n Le reste est: ");
- print_poly(reste1);
- printf ("\n");
- }
Add Comment
Please, Sign In to add comment