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 |
Re:这样到底有什么问题,还是请指教一下In Reply To:这样 Posted by:hz02ruc at 2004-03-01 15:43:56 #include "stdio.h" int init(int y[]) { int num; int i; if(scanf("%d",&num)==EOF) return 0; y[8]=num; for( i=7;i>=0;i--) scanf("%d",&y[i]); return 1; } main() { char x[9][4]={"","x","x^2","x^3","x^4","x^5","x^6","x^7","x^8"}; int i,y[9]; while(init(y)) { i=9; while(y[--i]==0); if(y[i]!=1&&y[i]!=-1) printf("%d%s",y[i],x[i]); else if(y[i]==1) printf("%s",x[i]); else printf("-%s",x[i]); while(--i) { if(y[i]==0) continue; if(y[i]!=1&&y[i]!=-1) if(y[i]>0) printf(" + %d%s",y[i],x[i]); else printf(" - %d%s",-y[i],x[i]); else if(y[i]==1) printf(" + %s",x[i]); else printf(" - %s",x[i]); } if(y[i]>0) printf(" + %d",y[i]); else if(y[i]<0) printf(" - %d",-y[i]); printf("\n"); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator