Guest User

Untitled

a guest
May 24th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.34 KB | None | 0 0
  1. /* cette structure est utilisée dans la foncton d'affichage du resultat de la division euclidienne Affichage_diveucli */
  2. typedef struct
  3. {
  4.     Poly quotient;
  5.     Poly reste;
  6. } QuotientReste ;
  7.  
  8.  
  9. /* Division_Euclidienne fait la division euclidienne de  deux polynomes et retourne le resultat sous forme de quotient et reste */
  10. QuotientReste Division_Euclidienne (Poly p1, Poly p2)
  11. {
  12.     tidy_poly(p1);
  13.     tidy_poly(p2);
  14.  
  15.     Poly Q,quotient_final,R,reste_final;
  16.  
  17.     Q = malloc (sizeof (struct p_data));
  18.     R = malloc (sizeof (struct p_data));
  19.  
  20.     R->deg= p2->deg ;
  21.  
  22.     if (p1->deg >= p2->deg)
  23.         {
  24.     while (R->deg >= p2->deg)
  25.     {
  26.  
  27.             Q->deg = p1->deg - p2->deg ;
  28.             Q->coef = (p1->coef)/(p2->coef);
  29.  
  30.             R = poly_sub (p1,poly_mult(Q,p2)) ;
  31.  
  32.             Q=Q->red;
  33.             printf("bla");
  34.  
  35.             Q = Division_Euclidienne(R,p2).quotient;
  36.             R = Division_Euclidienne(R,p2).reste;
  37.  
  38.         }
  39.  
  40.     }
  41.     quotient_final = Q ;
  42.     reste_final = R ;
  43.  
  44.     tidy_poly(quotient_final);
  45.     tidy_poly(reste_final);
  46.  
  47.     QuotientReste resultat;
  48.     resultat.reste = reste_final ;
  49.     resultat.quotient = quotient_final;
  50.     //printf( "Le quotient est:");
  51.     //print_poly(quotient_final);
  52.     //printf("\n.Le reste est:");
  53.     //print_poly(reste_final);
  54.  
  55.     return (resultat) ;
  56. }
Add Comment
Please, Sign In to add comment