#include<iostream>
template<unsigned int a,unsigned int b>
struct GCD
{
static const unsigned int value=GCD<b,a%b>::value;
};
template<unsigned int a>
struct GCD<a,0>
{
static const unsigned int value=a;
};
int main()
{
std::cout<<GCD<15996,6456>::value<<std::endl;//随意一个例子
}
最大公约数(GCD)的模板元编程
最新推荐文章于 2025-04-17 18:13:32 发布