data-structures - 使用霍纳规则评估多项式
问题描述
这个问题的第二个循环不起作用。我正在尝试打印出对霍纳规则的评估,但由于第二个循环,我没有得到正确的输出。
#include <stdio.h>
int main()
{
float a[100], x, sum = 0;
int n;
printf("enter the degree of polynomial : ");
scanf("%d", &n);
printf("enter the coefficient of polynomial : \n ");
for (int i = n; i <= n; i--)
{
printf("enter the coefficiient for x^%d\n", i);
scanf("%f", &a[i]);
if (i == 0)
{
break;
}
}
printf("enter the value : ");
scanf("%f", &x);
for (int i = n ; i < n; i++)
{
sum = (sum + a[i]) * x;
}
printf("the vlaue of polynomial is %f\n", sum);
return 0;
}
解决方案
推荐阅读
- javascript - jwt 刷新令牌反应
- python - Checkbox using xpath not accessible
- activemq - ActiveMQ doesn't open default port when launching
- arrays - BASH: How to read TAB-separated line with empty colums from file into array
- javascript - Guild 在命令处理程序中未定义
- java - How to sum the elements of the array up to the target number?
- java - 如何在 Android Java 中记录对象?
- wordpress - wp_validate_auth_cookie interfering on Woocommerce API
- prism - Prism View Navigation 在带有重音符号的注册名称上失败
- wordpress - Display attribute images ( Woocommerce )