#include<stdio.h> int main() { unsigned int n,i; unsigned long sum=0; printf("请输入乘方值:"); scanf("%u",&n); for(i=1;i<=n;i++) sum+=i*i; printf("%lu",sum); return 0; }
#include<stdio.h> int main() { unsigned int n,i,j; unsigned long sum=0,pow; printf("请输入乘方值:"); scanf("%u",&n); for(i=1;i<=n;i++) { pow=1; for(j=1;j<=i;j++) { pow*=i; } sum+=pow; } printf("%lu",sum); return 0; }