error
Recently want to use __gcd(a, b)
computing a
and b
the greatest common divisor, the results encountered the following error:
[Error] '__gcd' was not declared in this scope
Solution
Because the __gcd()
function is defined in the standard library <algorithm>
, just add it #include <algorithm>
.
Example:
#include <cstdio>
#include <algorithm>
using namespace std;
int main(void)
{
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", __gcd(a, b));
return 0;
}