思路:先计算出阶乘之和,再把sum逐个拆解判断。
#include <stdio.h>
int main()
{
int n, s1=1 ,s2=0,b;
scanf_s("%d", &n);
//求阶乘和
for (int i = 1; i <= n; i++)
{
s1 = s1 * i;
s2 = s1+s2;
}
printf("%d\n", s2);
//判断结果里是否含有n
if (s2 >= 10)
{
b = s2 % 10;
}
else
{
b = s2;
}
if (b == n)printf("1");
else printf("0");
return 0;
}