题目传送门

#include <bits/stdc++.h>

using namespace std;
const int N = 110;

int main() {
    int n;
    cin >> n;
    int x;
    // a[0~n-1]是系数,a[n]是常数
    for (int i = 0; i < n; i++) {
        cin >> x;
        //带x的前0->n-1位
        if (x < 0) {
            if (x == -1)cout << "-"; else cout << x;
        } else if (x > 0) {
            if (i > 0) cout << "+";
            if (x != 1) cout << x;
        } else continue;
        if (n - i > 1) cout << "x^" << n - i;
        else cout << "x";
    }

    //常数位
    cin >> x;
    if (x > 0) cout << "+" << x; else if (x < 0) cout << x;
    return 0;
}

相关文章:

  • 2021-06-01
  • 2021-07-01
  • 2021-06-18
  • 2022-12-23
  • 2022-01-07
  • 2021-10-08
  • 2022-12-23
猜你喜欢
  • 2021-10-27
  • 2021-09-15
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2021-09-03
相关资源
相似解决方案