今天做水仙花数的时候谢了一段代码,但是发现sublime下运行结果与gc++6.0编译结果不一致,记录以究。
#include <stdio.h> #include <math.h> int main(int argc, char const *argv[]) { int n = 0, a = 0, x = 0, t = 0; for (int i = 0; i < 500; ++i) { n = i; t = 0; while(n != 0) { a = n % 10; t += pow(a,3); n /= 10; } if (t == i) { printf("M", i); /*x++; if (x % 10 == 0) { printf("\n"); }*/ } } return 0; }
转载请注明原文地址: https://ju.6miu.com/read-40233.html