#include
using namespace std;
int main()
{
int fact[11] = {1}, i;
for (i = 1; i <= 10; i ++)
fact[i] = fact[i-1]*i; //求阶乘
int a, b, c;
bool need_to_be_different = false; //每位是否需要不同
for (a = 1; a <= 9; a ++)
for (b = 0; b <= 9; b ++)
for (c = 0; c <= 9; c ++)
{
if (need_to_be_different)
if (a == b || a == c || b == c)
continue;
if (100*a+10*b+c == fact[a]+fact[b]+fact[c])
cout< }
return 0;
}
#include
int n(int i)
{
if(i>1)
return i*n(i-1);
else if(i==1)
return i;
}
int main()
{
for(int a = 1;a<=9;a++)
for(int b = 1;b<=9;b++)
for(int c = 1;c<=9;c++)
if(a!=b && b!=c && c!=a && (n(a)+n(b)+n(c)) == (a*100+b*10+c))
std::cout<
return 0;
}
呵呵,楼上longinus_dean,C++ 中阶乘不能直接用“!”哦,要计算哦
惊叹号是什么意思
不明白
不知是不是
abc=100a+10b+c