提交时间:2023-08-22 21:37:18

运行 ID: 99496

#include<iostream> using namespace std; bool f; int main() { int n; cin >> n; for (int i{ n }; i > 0; i--) { int j; cin >> j; if (j == 0) continue; if (j > 1 && !f || j < -1) cout << j; else if (j == 1 && f) cout << '+'; else if (j == 1 && !f); else if (j == -1) cout << '-'; else cout << '+' << j; cout << "x^"; cout << i; f = true; } cin >> n; if (f && n > 0) cout << '+' << n; if (!f || f && n < 0) cout << n; return 0; }