编写主函数根据用户输入的两个整数调用函数gcd_lcm求解并输出它们的最大公约数和最小公倍数。
输出语句格式:
cout<<"Please input two integers: ";
cout<<"The GCD of them is "<<…<<endl;
cout<<"The LCM of them is "<<…<<endl;
输入输出实例1:
Pleae input two integers: 12 24
The GCD of them is 12
The LCM of them is 24
输入输出实例2:
Pleae input two integers: 12 56
The GCD of them is 4
The LCM of them is 168
参考程序模板:
#include <iostream>
using namespace std;
//only necessary output statments are given here
void gcd_lcm( int num1, int num2, int &gcd, int &lcm ) ;
int main()
{
//to add other statements you need
cout<<"Please input two integers: ";
//to add other statements you need
cout<<"The GCD of them is "<<gcd<<endl;
cout<<"The LCM of them is "<<lcm<<endl;
return 0;
}
void gcd_lcm( int num1, int num2, int &gcd, int &lcm )
{
//to add statements to solve gcd and lcm
}