You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include<bits/stdc++.h>
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
void max_min(int &m, int &n) {
|
|
|
|
|
int tmp;
|
|
|
|
|
if(m<n) {
|
|
|
|
|
tmp=m;
|
|
|
|
|
m=n;
|
|
|
|
|
n=tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC>:շת<D5B7><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int Cal_GCD(int m, int n) {
|
|
|
|
|
int gcd;
|
|
|
|
|
max_min(m, n);
|
|
|
|
|
gcd=m%n;
|
|
|
|
|
while(gcd) {
|
|
|
|
|
m=n;
|
|
|
|
|
n=gcd;
|
|
|
|
|
gcd=m%n;
|
|
|
|
|
}
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
int main() {
|
|
|
|
|
int m, n, gcd;
|
|
|
|
|
|
|
|
|
|
printf("Enter two num a b: ");
|
|
|
|
|
scanf("%d %d", &m, &n);
|
|
|
|
|
gcd=Cal_GCD(m, n);
|
|
|
|
|
printf("%d and %d GCD: %d\n", m, n, gcd);
|
|
|
|
|
//<2F><>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
printf("%d and %d LCM: %d\n", m, n, m*n/gcd);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|