提交时间:2023-08-22 21:31:58

运行 ID: 99495

#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, f = true; else if (j == 1) cout << '+'; else if (j == -1) cout << '-'; else cout << '+' << j; cout << "x^"; cout << i; } cin >> n; if (f && n > 0) cout << '+' << n; if (!f || f && n < 0) cout << n; return 0; }