倾世冷悠


私信TA

用户名:15059881879

访问量:12678

签 名:

2022.3.7我回来啦,备研啦

等  级
排  名 274
经  验 5660
参赛次数 23
文章发表 35
年  龄 20
在职情况 学生
学  校 TYKJDX
专  业 智能科学与技术

  自我简介:

一个萌新,还望各位大佬多多指教

 

0.0分

3 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

有时候我真的觉得这个网站的oj系统有点问题。。。
我的就过不了,明明答案都一样的。。。难受。。。
#include<iostream>
#include<stdio.h>
using namespace std;
double fact(int a)
{
	int b = 1;
	for (int i = 1; i <= a; i++)	b *= i;
	return b;
}
double mypow(double x, int a)
{
	double y = x;
	for (int i = 0; i < a - 1; i++)	x *= y;
	return x;
}
int main()
{
	int n;
	double sum = 0, x;
	scanf("%lf%d", &x, &n);
	for (int i = 1; i <= n; i++)
	{
		double y = x;
		sum += (mypow(-1, i-1)) * (mypow(y, i) / fact(i));
	}
	printf("%.4lf", sum);
	return 0;
}
2020-04-18 14:27:21
https://blog.dotcpp.com/a/8729   这个题解了解下,和循环变量是int还是double没有关系啊。
2020-02-15 17:12:15
  • «
  • 1
  • »