#include<stdio.h>
void main()
{ int a, b, d, e = 0; for (a = 1;; a++) { do { b = a % 10; d = a / 10; e = e + b*b*b; a = d; } while (d> 0); if (a == e) printf(" %d\n", e); }
}
调试时不能输出结果,但在VS2013上没有警告或错误
你的程序死循环,而且每次执行除了e其他都是一样的
#include<stdio.h>
void main()
{ int a, b, d, e = 0; for (a = 1;; a++)//a=1 { do { b = a % 10; //b = 1 d = a / 10; //d = 0 e = e + b*b*b; //e = 1,2,3... a = d;//a = 0 } while (d> 0); //false if (a == e)//false printf(" %d\n", e); }
}