多项式输出50pts求助,大大滴感谢

P1067 [NOIP2009 普及组] 多项式输出

代码如下 ```cpp #include <iostream> using namespace std; int main() { int n, x; cin >> n; n++; cin >> x; if (n == 1) { cout << x << endl; return 0; } if(x<0) cout<<'-'; if (abs(x)!=1) cout<<abs(x); cout << "x^" << n-1 ; for (int i = n - 2; i >= 1; i--) { cin >> x; if (x == 0) continue; if (x > 0) { cout << "+"; } else { cout << "-"; } if (abs(x ) != 1) cout << abs(x); if(i!=1) cout << "x^" << i; else cout<<"x"; } cin >> x; if (x != 0) { if (x >= 0) cout << '+'; cout << x; } cout << endl; } ```
by jeffrey @ 2023-08-01 20:35:44


你没有判断幂=1的情况
by jeffrey @ 2023-08-01 20:37:38


|