cpp

A05.36 计算多项式的值

a. 参考代码

#include <iostream>
#include <cmath>
using namespace std;

int main(){
    long int n;
    double x,f = 1,p;

    cin >> x >> n ;
    f = f + x;
    for (int i=2;i<=n;i++)
        f = f + pow(x,i);
    printf("%.2f",f);   
    
    return 0;
}

w. 微信订阅号

  1. 智数精英-关注中小学程序设计及相关讨论
  2. 随话录-记录小朋友们的成长时光
  3. 西山征途-关注大学生成长、学习和生活

欢迎关注“智数精英”订阅号 欢迎关注“随话录”订阅号 欢迎关注“西山征途”订阅号


b. 返回

h. 首页