提是什么意思,我写的错哪了
  • 板块B2147 求 f(x,n)
  • 楼主ZiruiLIU
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/6/9 18:53
  • 上次更新2024/6/9 18:56:37
查看原帖
提是什么意思,我写的错哪了
1128297
ZiruiLIU楼主2024/6/9 18:53
#include<bits/stdc++.h>
using namespace std;
double x;
int n;
double f(double x, int  n) {
	if (n == 1) {
		return 1 + x;
	} else {
		//	cout<<n<<" "<<x<<endl;
		return n + f(x, n - 1);
	}

}
int main() {
	cin >> x >> n;
	printf("%.2f", f(x, n)) ;
	return 0;
}
2024/6/9 18:53
加载中...