⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nullzeros.cpp

📁 This library defines basic operation on polynomials, and contains also 3 different roots (zeroes)-fi
💻 CPP
字号:
// nullzeros.cpp : Demonstrates use of removeNullZeros
//
#include <iostream>
#include "polyzero.h"

using namespace std;

void main() {
    //  this example shows how to remove null roots from a polynomial
    //  using removeNullRoots()

    //  create polynomial p(x)=x^3+x^2 (= x*x*(x+1))
    Polynomial<float> p(3, 0.f, 0.f, 1.f, 1.f);

    // print
    cout << "before deflating P(x)=";
    for (int i = p.degree(); i >= 1; --i)
        cout << p[i] << "*x^" << i << "+";
    cout << p[0] << endl << endl;
        
    int n = removeNullZeros(p);

    cout << "removeNullZeros() removed " << n << " zeros" << endl;

    // print modified polynomial
    cout << "after deflating P(x)=";
    for (int i = p.degree(); i >= 1; --i)
        cout << p[i] << "*x^" << i << "+";
    cout << p[0] << endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -