C++ 报错 'gcd' was not declared in this scope
C++ 报错 'gcd' was not declared in this scope
最近想用gcd(a, b)
计算a
和b
的最大公约数,结果遇到如下错误:
[Error] 'gcd' was not declared in this scope
解决方法
用的时候不要忘记了__
示例:
#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;
}