解题思路:
注意事项:
参考代码:
#include<stdio.h> int main() { for(int i=1;i<=9;i++) { int jc=1,sum=0; for(int a1=1;a1<=i;a1++) { jc*=a1; } sum+=jc; if(sum==i) { printf("%d ",i); } ; for(int a1=i*10;a1>=i*10&&a1<(i+1)*10;a1++) { jc=1,sum=0; for(int s=1;s<=a1/10%10;s++) { jc*=s; } sum+=jc; jc=1; for(int g=1;g<=a1%10;g++) { jc*=g; } sum+=jc; jc=1; if(sum==a1) { printf("%d",sum); } } for(int a1=i*100;a1>=i*100&&a1<(i+1)*100;a1++) { jc=1,sum=0; for(int b=1;b<=a1/100;b++) { jc*=b; } sum+=jc; jc=1; for(int s=1;s<=a1/10%10;s++) { jc*=s; } sum+=jc; jc=1; for(int g=1;g<=a1%10;g++) { jc*=g; } sum+=jc; jc=1; if(sum==a1) { printf("%d ",a1); } } for(int a1=i*1000;a1>=i*1000&&a1<(i+1)*1000;a1++) { jc=1,sum=0; for(int q=1;q<=a1/1000;q++) { jc*=q; } sum+=jc; jc=1; for(int b=1;b<=a1/100%10;b++) { jc*=b; } sum+=jc; jc=1; for(int s=1;s<=a1/10%10;s++) { jc*=s; } sum+=jc; jc=1; for(int g=1;g<=a1%10;g++) { jc*=g; } sum+=jc; jc=1; if(sum==a1) { printf("%d ",a1); } } for(int a1=i*10000;a1>=i*10000&&a1<(i+1)*10000;a1++) { jc=1,sum=0; for(int w=1;w<=a1/10000;w++) { jc*=w; } sum+=jc; jc=1; for(int q=1;q<=a1/1000%10;q++) { jc*=q; } sum+=jc; jc=1; for(int b=1;b<=a1/100%10;b++) { jc*=b; } sum+=jc; jc=1; for(int s=1;s<=a1/10%10;s++) { jc*=s; } sum+=jc; jc=1; for(int g=1;g<=a1%10;g++) { jc*=g; } sum+=jc; jc=1; if(sum==a1) { printf("%d ",a1); } } } return 0; }
0.0分
1 人评分
C语言训练-排序问题<1> (C++代码)浏览:633 |
A+B for Input-Output Practice (VI) (C++代码)浏览:445 |
WU-蓝桥杯算法提高VIP-企业奖金发放 (C++代码)浏览:1270 |
WU-陶陶摘苹果2 (C++代码)浏览:1018 |
C语言训练-亲密数 (C语言代码)浏览:697 |
DNA (C语言描述,蓝桥杯)浏览:1654 |
sizeof的大作用 (C语言代码)浏览:1598 |
简单的a+b (C语言代码)浏览:491 |
C语言程序设计教程(第三版)课后习题9.1 (C语言代码)浏览:653 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:560 |