悬棺,最后两个WA了
查看原帖
悬棺,最后两个WA了
1229233
wzrwzr楼主2025/7/23 21:34

悬棺,求调

#include<bits/stdc++.h>
using namespace std;
int a,b; 
int main(){
cin>>a;
for(int i=a;i>=0;i--){
cin>>b;
if(b!=0){
if(i>1){
if(b<0&&b!=-1)cout<<b<<"x^"<<i;
else if(b==-1)cout<<"-x^"<<i;
else if(b==1&&i!=a)cout<<"+x^"<<i;
else if(b==1&&i==a)cout<<"x^"<<i;
else if(i!=a)cout<<'+'<<b<<"x^"<<i;
else cout<<b<<"x^"<<i;
}
else if(i==1){
if(b<0&&b!=-1)cout<<b<<"x";
else if(b==-1)cout<<"-x";
else if(b==1)cout<<"+x";
else cout<<'+'<<b<<"x^";
}
else {
if(b<0)cout<<b;
else cout<<"+"<<b;
}

}
}
return 0;}

2025/7/23 21:34
加载中...