C ++で報告されたエラー「__gcd」はこのスコープで宣言されていません

エラー

最近__gcd(a, b)コンピューティングab最大公約数を使用したい場合、結果で次のエラーが発生しました。

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

おすすめ

転載: blog.csdn.net/write_1m_lines/article/details/104753636