[单选题]

有以下程序:includeusing namespace std;int f(int x);int sum(int n){ int x,s=0; f

有以下程序: #include<iostream> using namespace std; int f(int x); int sum(int n) { int x,s=0; for(x = 0;x<=n;x++) s+=f(x); return s; } int f(int x) { return (x*x+1); } int main() { int a,b; cout<<"Enter a integer number:"; cin>>a; b=sum(a) ; cout<<a<<","<<b<<end1; return 0; } 如果输入数字3,其输出结果是( )。

A.3,12

B.3,16

C.3,18

D.4,20

参考答案与解析: