tijie
2023-08-19 10:05:44
发布于:广东
1阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main(){
int n;
cin>>n;
for(int i=n+1;i>=1;i--){
cin>>a[i];
}
for(int i=n+1;i>=1;i--){
if(a[i]==0) continue;
if(i==n+1){
if(a[i]==-1) cout<<"-x^"<<n;
else if(a[i]==1) cout<<"x^"<<n;
else cout<<a[i]<<"x^"<<n;
}else if(i==1){
if(a[i]>0) cout<<"+"<<a[i];
else cout<<a[i];
}else if(i==2){
if(a[i]==1) cout<<"+x";
else if(a[i]==-1) cout<<"-x";
else{
if(a[i]>0) cout<<"+"<<a[i]<<"x";
else cout<<a[i]<<"x";
}
}
else{
if(a[i]>0){
if(a[i]==1) cout<<"+x^"<<i-1;
else cout<<"+"<<a[i]<<"x^"<<i-1;
}
else{
if(a[i]==-1) cout<<"-x^"<<(i-1);
else cout<<a[i]<<"x^"<<i-1;
}
}
}
return 0;
}
这里空空如也
有帮助,赞一个