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 |
我测试了所有贴里给出的数据,都是对的,为什么总是WA呢?#include <stdio.h> #include<string.h> #include<stdlib.h> #define len 100 int point; void mul(int val[],int n,int v) { int i,j,t=0; for(i=0;i<len-1;i++) val[i]=0; val[len-1]=1; for(j=0;j<n;j++) { for(i=len-1;i>=0;i--) { val[i]=val[i]*v; } for(i=len-1;i>=0;i--) { val[i]+=t; t=val[i]/10; val[i]%=10; } } } void main() { char r[6]; double r1; int n,i,j,k=0,p,t,v; int val[len],val1[100][len],point1[100]; while(scanf("%s%d",r,&n)==2) { for(i=0;r[i]!='\0';i++){} for(;i<6;i++) r[i]='0'; for(i=0,v=0;i<6;i++) { if(r[i]!='.') { t=r[i]-'0'; v=v*10+t; } else { point=(5-i)*n; r1=v; } } r1=(double)strtod(r,NULL); if(r1<=0.0||r1>=99.999||n>25||n<=0) continue; mul(val,n,v); point1[k]=point; for(i=0;i<len;i++) { val1[k][i]=val[i]; } k++; } for(p=0;p<k;p++) { for(j=len-1;val1[p][j]==0&&j>=len-point1[p];j--){} for(i=0;val1[p][i]==0&&i<len-point1[p];i++){} for(;i<len-point1[p];i++) { printf("%d",val1[p][i]); } if(j+1!=len-point1[p]) printf("."); for(;i<=j;i++) { printf("%d",val1[p][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