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:为什么还是错的呢?(附程序如下)(help!!!!!!!!)In Reply To:Re:为什么还是错的呢?(附程序如下)(help!!!!!!!!) Posted by:dhm at 2005-05-23 22:17:35 我的也是 #include <stdio.h> #include <string.h> #define N 1000 int main() { char result[N+1]; char temp[7]; char sum[N+1],save[N+1]; char inp[10]; int num,i,j,k,flag,point,have,eh,top; while(scanf("%c",inp)!=-1) { have=0; gets(inp+1); if(inp[7]!=32) num=10*(inp[7]-'0')+inp[8]-'0'; else num=inp[8]-'0'; for(i=0;i<N;i++) { result[i]=0; sum[i]=0; save[i]=0; } flag=4; for(i=0;i<6;i++) { if(inp[i]=='.') { eh=0; point=(5-i)*num; for(j=i+1;j<6;j++) if(inp[j]!='0') eh=1; if(eh==0) have=1; continue; } save[flag]=temp[flag]=inp[i]-'0'; flag--; } if(num==1) { if(have==0) { for(i=0;i<6;i++)//前0 if(inp[i]=='.') { for(j=0;j<=i;j++) { if(inp[j]!='0') {top=j;break;} if(inp[j]=='.') top=j; } } for(j=5;j>0;j--) if(inp[j]!='0') break; for(i=top;i<=j;i++) { printf("%c",inp[i]); } printf("\n"); continue; } i=0;eh=0; while(inp[i]!='.') { if(inp[i]!='0') eh=1; if(eh==1) printf("%c",inp[i]); i++; } printf("\n"); continue; } for(k=0;k<num-1;k++) //主算法 { for(j=0;j<N;j++) result[j]=0; for(i=0;i<5;i++) { if(temp[i]==0) continue; flag=0; for(j=0;j<N;j++) sum[j]=0; for(j=0;j<N;j++) sum[j]=save[j]; for(j=0;j<N;j++) { sum[j]=temp[i]*sum[j]+flag; flag=sum[j]/10; sum[j]=sum[j]%10; } flag=0; for(j=0;j<N-i;j++) { result[j+i]+=sum[j]+flag; flag=result[j+i]/10; result[j+i]=result[j+i]%10; } } for(j=0;j<N;j++) save[j]=result[j]; } flag=0; num=-1; for(i=0;i<N;i++) { if(result[i]==0) {num++;continue;} break; } for(i=N-1;i>num;i--) { // if(have==1) {i=point;flag=1;} if(result[i]!=0) flag=1; if(i==point-1) { printf("."); flag=1; } if(flag==0) continue; printf("%c",result[i]+'0'); } printf("\n"); continue; } return 0; } bt数都没问题啊 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator