1.模拟理清题目要求,按照题目要求逐个实现,注意特殊情况,最好用笔写出来,不然直接思考太难了
#include <bits/stdc++.h>
using namespace std;int main() {int n; cin >> n;int a;for (int i =n; i>=0; i--) {cin >> a;if (a == 0)continue;if (a > 0 && i < n)cout << '+';if (a != 1 && a != -1 || i == 0)cout << a;if (a == -1 && i > 0)cout << '-';if (i > 1)cout << "x^"<<i;if (i == 1)cout << 'x';}return 0;
}