错误
最近想用__gcd(a, b)计算a和b的最大公约数,结果遇到如下错误:
[Error] '__gcd' was not declared in this scope
解决方法
因为__gcd()函数定义在标准库<algorithm>中,所以加上#include <algorithm>即可。
示例:
#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;
}
518



被折叠的 条评论
为什么被折叠?



