提交时间:2023-08-22 17:11:54

运行 ID: 99425

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