27、求解n阶多项式的值,多项式公式如下
2024-10-20 15:46:12
/*
求解n阶多项式的值,多项式公式如下:
Pn(x) = 1 n=0;
= x n = 1;
= (2n - 1)xPn-1(x) - (n - 1)Pn-2(x) n>=2
*/
#include <stdio.h>
#include <stdlib.h>
float Pn(int n,float x)
{
if(n == 0)
return 1;
else if(n == 1)
return x;
else
return (2 * (n-1) + 1) * x * Pn(n-1,x) - (n - 1) * Pn((n -1 ) - 1,x);
//return (2 * n - 1) * x * Pn(n-1,x) - (n - 1) * Pn(n - 2,x);
}
int main()
{
int n;
float x;
printf("Enter n:");
scanf("%d", &n);
printf("Enter x:");
scanf("%f", &x);
printf("%f", Pn(n,x));
return 0;
}
最新文章
- Linux 部署 nginx服务代理
- WindowsForm--Bubble User Control
- XMPP客户端开发(2)--发送接收消息
- CodeForces 478C Table Decorations
- SQL Server 一些关键字详解(二)
- redundant 行记录格式
- 理解 backbone.js 中的 bind 和 bindAll 方法,关于如何在方法中指定其中的 this,包含apply方法的说明[转载]
- JavaScript之arguments.callee
- Java消息服务初步学习(基于Spring In Action的整理)
- 升级python(linux)
- BZOJ 2726: [SDOI2012]任务安排 [斜率优化DP 二分 提前计算代价]
- 【树莓派】GSM900模块
- Redis安装系统服务1073错误
- (转载)Javascript异步编程的4种方法
- mysql 理解索引,添加索引,使用索引(哪些情况会导致索引失效)
- ZThread::ThreadLocal:ERROR C4716 must return a value的解决
- JAVA三框架工作原理是什么?
- Android滑动删除功能
- Linux中的awk命令
- Data Structure Binary Tree: Construct Full Binary Tree from given preorder and postorder traversals
热门文章
- 面试~jvm(JVM内存结构、类加载、双亲委派机制、对象分配,了解垃圾回收)
- KingbaseES R6 集群repmgr.conf参数&#39;recovery&#39;测试案例(一)
- 二进制redis集群部署
- 华南理工大学 Python第7章课后小测-1
- Elasticsearch6.2服务器升配后的bug
- ProxySQL(5):线程、线程池、连接池
- 分布式安装部署MinIO
- 新版本中的hits.total匹配数说明
- GitLab 之 PlantUML 的配置及使用
- 记录一次Bitbucket鉴权的坑