用c++编写程序:当x>1时,Hermite多项式定义如下,它用于求第n项的值
时间: 2023-05-31 20:03:38 浏览: 149
#include <stdio.h>
int main()
{
int n, x;
printf("Enter the value of n: ");
scanf("%d", &n);
printf("Enter the value of x: ");
scanf("%d", &x);
int h0 = 1, h1 = 2 * x;
int hn = 0;
for (int i = 2; i <= n; i++) {
hn = 2 * x * h1 - 2 * (i - 1) * h0;
h0 = h1;
h1 = hn;
}
printf("The value of H%d(%d) is %d\n", n, x, hn);
return 0;
}
阅读全文