求助10PTS

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

@[xzabc123](/user/464158) 输入: ``` 5 5 4 3 2 1 0 ``` read: ``` 5x^5+4x^4+3x^3+2x^2+1x^10 ``` expected: ``` 5x^5+4x^4+3x^3+2x^2+x ``` 问题蛮多的(( 这是我的代码(稍微长了那么~~亿~~一点点): ```cpp #include <iostream> using namespace std; int n, t, m; int main(){ cin >> m; n = m; if(n == 0){ cout << "0" << endl; return 0; } while(n != -1){ cin >> t; if(n == 0){ if(t > 0){ cout << "+" << t; } else if(t < 0){ cout << t; } } else { if(n == m){ if(t > 0){ if(t == 1){ if(n != 1) cout << "x^" << n; else cout << "x"; } else { if(n != 1) cout << t << "x^" << n; else cout << t << "x"; } } else if(t < 0){ if(t == -1){ if(n != 1) cout << "-x^" << n; else cout << "-x"; } else { if(n != 1) cout << t << "x^" << n; else cout << "t" << "x"; } } } else { if(t > 0){ if(t == 1){ if(n != 1) cout << "+x^" << n; else cout << "+x"; } else { if(n != 1) cout << "+" << t << "x^" << n; else cout << "+" << t << "x"; } } else if(t < 0){ if(t == -1){ if(n != 1) cout << "-x^" << n; else cout << "-x"; } else { if(n != 1) cout << t << "x^" << n; else cout << t << "x"; } } } } n--; } return 0; } ```
by achjuncool @ 2022-06-27 21:23:27


@[xzabc123](/user/464158) 还是建议看题解(~~我的代码太那个了~~
by achjuncool @ 2022-06-27 21:24:04


@achjuncoo谢谢
by xzabc123 @ 2022-06-30 13:02:06


|