#include using namespace std; int main() { int n = 1, sum = 0, t = 1, j = 1; while (n <= 6) { sum = sum + t; n++; t = 1; do { t = t * n; j++; } while (j <= n); j = 1; } cout <<"1+2的平方+3的3次方+4的4次方+5的5次方+6的6次方=" < return 0; }
#include using namespace std; int main() { int sum = 0, n = 1, t=1, j; do { sum = sum + t; n++; t = 1; j=1; for (j = 1; j <= n; j++) t = t * n; }while (n<=6); cout<<"1+2的平方+3的3次方+4的4次方+5的5次方+6的6次方="<return 0; }
#include using namespace std; int main() { int sum = 0, n , t = 1, j ; for (n = 1; n <= 6 ; ) { sum = sum + t; n++; t = 1; j = 1; while (j <= n) { t = t * n; j++; } } cout<<"1+2的平方+3的3次方+4的4次方+5的5次方+6的6次方="<return 0; }