shunxinruyi @ 2024-12-03 14:51:27
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cmath>
using namespace std;
int xi[210];
int main()
{
int n;
cin>>n;
for(int i=n+1;i>=1;i--)
{
cin>>xi[i];
}
int m=n;
cout<<xi[n+1]<<"x^"<<n;
for(int i=n;i>1;i--)
{
m--;
if(xi[i]!=0)
{
if(xi[i]==1)
{
cout<<"+x^"<<m;
}
else if(xi[i]==-1)
cout<<"-x^"<<m;
else
cout<<xi[i]<<"x^"<<m;
}
}
if(xi[1]>0)
cout<<"+"<<xi[1];
else if(xi[1]<0) cout<<xi[1];
}
by taqingqiu @ 2024-12-03 15:05:46
为什么要倒着输出?正着输出应该会好一点,不容易错
by 001_zip @ 2024-12-10 18:30:59
要是xi[n+1]=0怎么办