- //INCLUDES
- #include <iostream>
- using namespace std;
-
- //PROTOTYPES
- int swap(int *a, int *b);
-
-
- //MAIN
- int main()
- {
-
- int a;
- int b;
- int resultat;
- int temp2;
- bool vf=true;
-
- cin>>a;
- cin>>b;
-
-
- //Pour que a soit supérieur à b:
- if(a>b)
- {
- cout<<"a est superieur a b"<<endl;
- }
-
- else
- {
- cout<<"b est superieure a a"<<endl;
- swap(&a,&b);
- }
-
- while(vf)
- {
- resultat=a-b;
-
-
-
- if(resultat<=b)
- {
- a=b;
- b=resultat;
- }
- if(resultat>b)
- {
- a=resultat;
- }
-
- if(resultat==0)
- {
- vf=false;
- cout<<"le pgcd est :"<<temp2<<endl;
- }
- temp2=resultat;
- }
-
-
-
-
-
-
-
-
- int fin;
- cin>>fin;
-
- return 0;
- }
-
- //FONCTIONS
-
- int swap(int *a, int *b)
- {
- int temp;
- temp=*a;
- *a=*b;
- *b=temp;
- }
-
//INCLUDES
#include <iostream>
using namespace std;
//PROTOTYPES
int swap(int *a, int *b);
//MAIN
int main()
{
int a;
int b;
int resultat;
int temp2;
bool vf=true;
cin>>a;
cin>>b;
//Pour que a soit supérieur à b:
if(a>b)
{
cout<<"a est superieur a b"<<endl;
}
else
{
cout<<"b est superieure a a"<<endl;
swap(&a,&b);
}
while(vf)
{
resultat=a-b;
if(resultat<=b)
{
a=b;
b=resultat;
}
if(resultat>b)
{
a=resultat;
}
if(resultat==0)
{
vf=false;
cout<<"le pgcd est :"<<temp2<<endl;
}
temp2=resultat;
}
int fin;
cin>>fin;
return 0;
}
//FONCTIONS
int swap(int *a, int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}