C++ 报错 'gcd' was not declared in this scope

C++ 报错 'gcd' was not declared in this scope

最近想用gcd(a, b)计算ab的最大公约数,结果遇到如下错误:

[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;
}

posted @ 2021-03-12 15:29  TR_Goldfish  阅读(768)  评论(0编辑  收藏  举报