标签:for 水仙花 技术 .com mamicode img color mic stdio.h
#include <stdio.h> int main() { long t,s; t=22; s=0; for (t=22;t<=1002;t+=20) s+=t; printf("%d",s); return 0; }
#include <stdio.h> int main() { long t,s; t=22; s=0; while (t<=1002) {s+=t; t+=20;} printf("%d",s); return 0; }
#include <stdio.h> int main() { long t,s; t=22; s=0; do {s+=t; t+=20; }while (t<=1002); printf("%d",s); return 0; }
int t,a,b,c,s; s=0; for(t=100;t<=999;t++) { a=t/100; b=(t-a*100)/10; c=t-a*100-b*10; if (t==a*a*a+b*b*b+c*c*c) {printf("%d\n",t); s++;} } printf("水仙花数共有%d个",s); return 0; }
#include <stdio.h> int main() { int s,a,b,c; s=0; for(a=1;a<=3;a++) for(b=a+1;b<=4;b++) for(c=b+1;c<=5;c++) { printf("%d%d%d ",a,b,c); printf("%d%d%d ",a,c,b); printf("%d%d%d ",b,a,c); printf("%d%d%d ",b,c,a); printf("%d%d%d ",c,b,a); printf("%d%d%d\n",c,a,b); s+=6; } printf("%d",s); return 0; }
标签:for 水仙花 技术 .com mamicode img color mic stdio.h
原文地址:https://www.cnblogs.com/p201821430041/p/10838447.html