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 |
怎么总是Presentation Error,那为朋友帮我看看!#include"stdio.h" #include"stdlib.h" int coefficient[9]; scan(int *a) { int i; for(i=0;i<9;i++) { if(scanf("%d",&a[i])<=0) return 0; } return 1; } int main() { int i,k; while(scan(coefficient)) { for(k=0;k<9;k++) { if(coefficient[k]!=0) break; } if(k<8) { if(k<7) { if(coefficient[k]>1) printf("%dx^%d",coefficient[k],8-k); else if(coefficient[k]==1) printf("x^%d",8-k); else if(coefficient[k]==-1) printf("-x^%d",8-k); else if(coefficient[k]!=0) printf("%dx^%d",coefficient[k],8-k); } for(i=k+1;i<7;i++) { if(coefficient[i]>1) printf(" + %dx^%d",coefficient[i],8-i); else if(coefficient[i]==1) printf(" + x^%d",8-i); else if(coefficient[i]==-1) printf(" - x^%d",8-i); else if(coefficient[i]!=0) printf(" - %dx^%d",coefficient[i]*(-1),8-i); } if(coefficient[7]>1) printf(" + %dx",coefficient[7]); else if(coefficient[7]==1) printf(" + x"); else if(coefficient[7]==-1) printf(" - x"); else if(coefficient[i]!=0) printf(" - %dx",coefficient[7]*(-1)); } if(k==9) printf("0"); else { if(k==8) printf("%d",coefficient[8]); else if(coefficient[8]>0) printf(" + %d",coefficient[8]); else if(coefficient[8]!=0) printf(" - %d",coefficient[8]*(-1)); } printf("\n"); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator