Răspuns:
#include <iostream>
using namespace std;
int cmmdc(int a,int b){
while(a != b)
{
if(a>b)
a -= b;
else
b -= a;
}
return a;
}
int main()
{
int a,b,cont=0;
while(true){
cout<<"a = ";cin>>a;cout<<endl;
cout<<"b = ";cin>>b;cout<<endl;
if(a<b)
break;
}
for(int i=a;i<=b;i++){
if(i%2==0){
cout<<i<<" ";
cont++;
}
}
cout<<endl;
cout<<"Numere totale pare in intervalul "<<a<<" "<<b<<" sunt : "<<cont<<endl;
cout<<"cmmdc ( "<<a<<", "<<b<<" ) = "<<cmmdc(a,b)<<endl;
cout<<"cmmdc ( "<<b<<", "<<a<<" ) = "<<cmmdc(b,a)<<endl;
return 0;
}
Explicație: