发布网友 发布时间:2022-05-18 16:18
共1个回答
热心网友 时间:2023-10-19 16:58
代码文本:
#include "stdio.h"
int fact(int n){
if(n==1 || n==0)
return 1;
return n*fact(n-1);
}
int main(int argc,char *argv[]){
int n,t,k,s;
printf("Please enter a positive integer...\nn=");
if(scanf("%d",&n)==1 && n>0){
printf("\n%d,",n);
for(k=1,t=n;t;t/=10,k*=10);
for(s=0,k/=10;k;k/=10){
printf(k>9 ? "%d+" : "%d=",t=fact(n/k%10));
s+=t;
}
printf(n==s ? "%d\nYes\n" : "%d\nNo\n",s);
}
else
printf("Input error, exit...\n");
return 0;
}
供参考……