- #include "chaine.h"
- #include "entreeSortie.h"
- #include "chaine.cpp"
- #include "entreeSortie.cpp"
-
- int pgcd (const int a, const int b );
-
- // calcul de maniere recursif le pgcd
- // de deux entiers a et b par soustraction
- void main ()
- {
- int a,b ; // 2 entiers
-
- saisir (a) ;
- saisir (b) ;
- afficher(pgcd (a,b)) ;
- saisir () ;
- }
-
- int pgcd (const int a, const int b )
- {
- int res ; // variable local
- res = 0 ;
- if ( a == b )
- {
- res = a ;
- }
- else
- {
- if ( a > b )
- {
- res = pgcd (a - b , a) ;
- }
- else
- {
- res = pgcd (a , b - a) ;
- }
- }
- return (res) ;
- }
-
-
-
#include "chaine.h"
#include "entreeSortie.h"
#include "chaine.cpp"
#include "entreeSortie.cpp"
int pgcd (const int a, const int b );
// calcul de maniere recursif le pgcd
// de deux entiers a et b par soustraction
void main ()
{
int a,b ; // 2 entiers
saisir (a) ;
saisir (b) ;
afficher(pgcd (a,b)) ;
saisir () ;
}
int pgcd (const int a, const int b )
{
int res ; // variable local
res = 0 ;
if ( a == b )
{
res = a ;
}
else
{
if ( a > b )
{
res = pgcd (a - b , a) ;
}
else
{
res = pgcd (a , b - a) ;
}
}
return (res) ;
}