#includeint f(int a){ int b; b=a*a+1; return b;}int sum(int n){ int a,b=0,c=0; for(a=0;a<=n;a++) b=b+f(a); return b;}void main(){ int a,b; printf("enter a integer:"); scanf("%d",&a); b=sum(a); printf("a=%d,b=%d\n",a,b);}
这样试试