- #include<iostream>
- using namespace std;
- int Gcd(int no1,int no2)
- {
- int temp;
- while(no2 != 0)
- {
- temp = no2;
- no2 = no1%no2;
- no1 = temp;
- }
- return no1;
- }
- int main()
- {
- int n1,n2;
- cout<<"Please cin two number,I will give the greatest common divisor of them!"<<endl;
- cout<<"Plese the NO1:";
- cin>>n1;
- cout<<"Plese the NO2:";
- cin>>n2;
- cout<<"The greatest common divisor of "<<n1<<" and "<<n2<<" is "<<Gcd(n1,n2)<<endl;
- return 0;
- }
最大公约数
最新推荐文章于 2024-05-20 20:16:31 发布