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> int shuru(int A[150],int B[150]){ int a=0; do{ scanf("%c",&A[a]); if (A[a]=='.'){ B[0]=a; a--; } if(A[a]==' '){ B[1]=a; a--; } a++; } while (A[a-1]!='\n'); return (a-2); } void rightmv(int A[150],int a){ int m; for(m=a;m>=0;m--){ A[149+m-a]=A[m]; A[m]=0; } } void chan(int A[150],int B[150],int a){ int b; for(b=149;b>=149-a;b--){ A[b]=A[b]-48; } for(b=0;b<=149;b++){ B[b]=A[b]; } } void leftmv(int C[150],int p){ int z; for(z=p;z<=149;z++){ C[z-p]=C[z]; } for(z=149;z>149-p;z--) C[z]=0; } void cacul(int A[150],int B[150],int i,int j){ int C[150]={0}; int D[150]={0}; int z,x,a,b; for(i;i>1;i--){ for(a=149;a>=0;a--){ for(b=149;b>=149-j;b--){ C[b]=A[a]*B[b]+C[b]; z=C[b]/10; C[b]=C[b]%10; C[b-1]=C[b-1]+z; } leftmv(C,149-a); for(z=0;z<=149;z++){ D[z]=C[z]+D[z]; } for(z=149;z>=0;z--){ if(D[z]>=10){ x=D[z]/10; D[z]=D[z]%10; D[z-1]=D[z-1]+x; } } for(z=0;z<=149;z++){ C[z]=0; } } for(z=0;z<=149;z++){ A[z]=D[z]; D[z]=0; } } } int quling1(int A[150],int j){ int a; for(a=150-j;a<=149;a++){ if(A[a]!=0) return 1; } return 0; } int quling2(int A[150],int j){ int a; for(a=149;a>=150-j;a--) if(A[a]!=0) return a; } void main(){ int a,i,j,m,n,x,y; int A[150]={0}; int B[150]={0}; i=shuru(A,B); m=B[0]; n=B[1]; B[0]=0; B[1]=0; if (A[n+1]!='\n'){ i=A[n+1]-48; A[n]=A[n]-48; i=A[n]*10+i; } else i=A[n]-48; A[n]=0; A[n+1]=0; rightmv(A,n-1); chan(A,B,n-1); cacul(A,B,i,n-1); if (m!=0){ j=(n-m)*i; for (a=10;a<=149;a++){ if (A[a]==0) continue; break; } for(a;a<=149-j;a++) printf("%d",A[a]); x=quling1(A,j); y=quling2(A,j); if (x==1){ printf("."); for(a=150-j;a<=y;a++) printf("%d",A[a]); } } if(m==0){ for (a=10;a<=149;a++){ if (A[a]==0) continue; break; } for(a;a<=149;a++) printf("%d",A[a]); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator