#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;

float LRD(int n,double x){
  double s;
  if(n==0) s=1.0;
  else if(n==1) s=x;
  else s=((2*n-1)*x*LRD(n-1,x)-(n-1)*LRD(n-2,x))/n;
  return s;
}

int main(){
  int n;
  double sum,x;
  clock_t start,finish;
  double total;
  cout<<"Please enter an natural number and a real number:"<<endl;
  cin>>n>>x;
  start=clock();
  sum=LRD(n,x);
  finish=clock();
  total=(double)(finish-start);
  cout<<"The value is:"<<sum<<endl;
  cout<<"The time of this running is "<<total<<endl;
  return 0;
}

c语言-勒让德多项式求解+时间测定的更多相关文章

  1. 4.18n阶勒让德多项式求解

    Q:编写程序,输入正整数n和任意数x,求出勒让德多项式的值Pn(x) #include <iostream> #include<cstdio> using namespace ...

  2. 2406: C语言习题 求n阶勒让德多项式

    2406: C语言习题 求n阶勒让德多项式 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 961  Solved: 570[Submit][Status ...

  3. 求n阶勒让德多项式

    Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 161  Solved: 105 [Submit][Status][Web Board] Descrip ...

  4. C语言多种方法求解字符串编辑距离问题的代码

    把做工程过程经常用的内容记录起来,如下内容段是关于C语言多种方法求解字符串编辑距离问题的内容. { if(xbeg > xend) { if(ybeg > yend) return 0; ...

  5. 用递归方法求n阶勒让德多项式的值

    /* Date: 07/03/19 15:40 Description: 用递归法求n阶勒让德多项式的值      { 1  n=0    Pn(x)= { x  n=1      { ((2n-1) ...

  6. 效率对比:各种语言构造100W个时间对象

    原本是用perl写了一个通过给定的时间范围来筛选一个比较大的日志文件.但是测试发现筛选130W行日志需要2分多钟,对其中几个低效率函数单独进行了效率测试,发现构造100W个时间对象所花时间也是个大户. ...

  7. Tecplot——为动画添加求解时间(翻译)

    翻译自:<Tecplot 360 Getting Started Manual>中的Scenic Detour: Add Solution Time Caption 首先展示效果: 在画图 ...

  8. C语言-12-日期和时间处理标准库详细解析及示例

    概述 标准库 提供了用于日期和时间处理的结构和函数 是C++语言日期和时间处理的基础 与时间相关的类型 clock_t,本质是:unsigned long typedef unsigned long ...

  9. C语言中的系统时间结构体类型

    在C语言涉及中经常需要定时触发事件,涉及到获取系统时间,其结构体类型有多种.Unix/Linux系统下有以下几种时间结构: 1.time_t 类型:长整型,一般用来表示从1970-01-01 00:0 ...

随机推荐

  1. Unix进程特性

    本篇文章主要总结分享记录一下运维工作中经常打交道的Unix进程.程序是代码的集合,而进程是运行中的程序产生的.那么进程都有那些特性呢?且看下文,部分经典且难懂的地方,使用python代码实现,可以让读 ...

  2. 341. Flatten Nested List Iterator展开多层数组

    [抄题]: Given a nested list of integers, implement an iterator to flatten it. Each element is either a ...

  3. 深入浅出iptables

    一. 防火墙是什么 1. 防火墙简述 防火墙是指设置在不同网络或网络安全域之间的一系列部件的组合,它能增强机构内部网络的安全性.它通过访问控制机制,确定哪些内部服务允许外部访问,以及允许哪些外部请求可 ...

  4. 监控磁盘IO

    一.添加userparameter_io.conf配置文件 在/etc/zabbix/zabbix_agentd.d下添加userparameter_io.conf, 文件内容如下: UserPara ...

  5. SpringBoot自定义拦截器实现

    1.编写拦截器实现类,此类必须实现接口   HandlerInterceptor,然后重写里面需要的三个比较常用的方法,实现自己的业务逻辑代码 如:OneInterceptor package com ...

  6. chrome crx下载路径

    chrome crx下载后会被删除,可在检查时粘贴出来,下载路径在: %localappdata%\Google\Chrome\User Data\Webstore Downloads 参考:http ...

  7. hadoop错误:Does not contain a valid host:port authority

    hadoop环境部署完,执行hdfs zkfc -formatZK命令时,提示如上图所示错误 错误内容: [root@study_1_1 hadoop]# hdfs zkfc -formatZK Ex ...

  8. Python 2.6 安装wxPython后提示"64.....32"错误解决办法

    ImportError: /usr/local/lib/wxPython-unicode-2.8.10.1/lib/python2.6/site-packages/wx-2.8-mac-unicode ...

  9. javascript总结23:javascript 数据类型与变量

    1  基本类型和引用类型 JavaScript中的数据类型分为两类:基本类型和引用类型 基本类型:直接存储值,画图解释 Number.String.Boolean Undefined.Null 引用类 ...

  10. Gym 100989L (DFS)

    AbdelKader enjoys math. He feels very frustrated whenever he sees an incorrect equation and so he tr ...