Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
!!!!!!!能不能帮我看看那里错了#include <cstdio> #include <cmath> int main() { int a[9]; while(scanf("%d %d %d %d %d %d %d %d %d",a+8,a+7,a+6,a+5,a+4,a+3,a+2,a+1,a)!=EOF) { bool flag = false; for(int i=8;i>=0;i--) { if(a[i]) { if(flag == false) { if(fabs(a[i])==1) { if(a[i]==-1&&i>1) printf("-x^%d",i); else if(a[i]==-1 && i==1) printf("-x"); else if(a[i]==-1 && i==0) printf("-1"); else { if(i>=2) printf("x^%d",i); else if(i==1) printf("x"); else if(i==0) printf("%d",a[0]); } } else { printf("%d",a[i]); if(i>1) printf("x^%d",i); else if(i==1) printf("x"); else if(i==0) printf("%d",a[0]); } flag = true; } else { if(i>=2) { if(a[i]>0) printf(" + "); else {printf(" - "); a[i]=-a[i];} if(a[i]!=1) printf("%d",a[i]); printf("x^%d",i); } else { if(i==1) { if(a[i]>0) printf(" + "); else {printf(" - "); a[i]=-a[i];} if(a[i]!=1) printf("%d",a[i]); printf("x",a[i]); } else if(i==0) { if(a[i]>0) printf(" + "); else {printf(" - "); a[i]=-a[i];} printf("%d",a[i]); } } flag = true; } } } if(!flag) printf("0"); puts(""); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator