40分跪求大佬帮助

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

Input file: 3 1 -100 0 0 Output file: x^3-100x^2
by ihan255 @ 2018-09-08 17:51:30


#include<bits/stdc++.h> using namespace std; int main(){ int n,a; cin>>n; for(int i=n;i>=0;i--){ cin>>a; if(a!=0){ if(i!=n&&a>0) cout<<"+"; if(abs(a)>1||i==0) cout<<a; if(a==-1&&i) cout<<"-"; if(i>1) cout<<"x^"<<i; if(i==1) cout<<"x"; } } return 0; }
by 天下第一! @ 2018-09-08 18:57:04


身为蒟蒻的我看别人的代码能力十分不足,这是我的源代码,所以请您自己研究一下好吗
by 天下第一! @ 2018-09-08 18:58:01


@[天下第一!](/space/show?uid=54101) Thanks♪(・ω・)ノ
by ihan255 @ 2018-09-08 19:40:05


@[天下第一!](/space/show?uid=54101) 只不过本蒟蒻想搞明白我哪里错了,但是还是谢谢您啦
by ihan255 @ 2018-09-08 19:43:14


#include<bits/stdc++.h> using namespace std; int main(){ int n,x; cin>>n; for(int i=n;i>=0;i--){ cin>>x; if(x){ if((i!=n)&&(x>0)) cout<<"+"; if((abs(x)>1)||(i==0)) cout<<x; if((x==-1)&&i) cout<<"-"; if(i>1) cout<<"x^"<<i; if(i==1) cout<<"x"; } } }
by StephenCurry30 @ 2018-09-09 11:35:05


这个题有好多细节,最高位系数为0的话次高位系数就会成为最高位,系数全部为0的话要输出0
by 0219nice @ 2018-09-12 21:02:05


@[0219nice](/space/show?uid=129019) 那我到底哪里错了呢QWQ
by ihan255 @ 2018-09-19 21:38:25


呜呜,有没有大佬啊
by ihan255 @ 2018-09-29 21:07:26


|