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 |
为什么我的程序在VC上运行完全正常,到了这里就是runtime-error程序如下 #include<stdio.h> int main() { int n=0,i=0,j=0,bit=5; char R[6],res[126]; int r1[125],r2[125]; int multiplication(int r1[],int r2[]); while(scanf("%s %d",R,&n)) { i=5; while(R[i]=='0') i--; j=5; for(i;i>=0;i--) { R[j]=R[i]; j--; } for(j;j>=0;j--) R[j]='0'; while(R[bit] != '.') bit--; for(i=bit;i>0;i--) R[i]=R[i-1]; for(i=124;i>119;i--) { r1[i]=r2[i]=R[i-119]-48; } for(i;i>=0;i--) { r1[i]=r2[i]=0; } bit=n * (5-bit); for(i=0;i<n-1;i++) { multiplication(r1,r2); } for(i=0;i<125-bit;i++) { res[i]=r1[i]+48; } if(i!=125) res[i]='.'; i++; for(i;i<126;i++) res[i]=r1[i-1]+48; i=0; while(res[i]=='0') i++; for(i;i<126;i++) printf("%c",res[i]); printf("\n"); } return 0; } int multiplication(int r1[],int r2[]) { static int save[125][125]; int i=0,j=0,k=0,temp=0; for(i=0;i<125;i++) for(j=0;j<125;j++) save[i][j]=0; for(i=124;i>=0;i--) { k=i; for(j=124;j>=0;j--) { temp=save[i][k]; save[i][k]=(r1[j]*r2[i]+save[i][k]) % 10; save[i][k-1]=(r1[j]*r2[i]+temp+save[i][k-1]*10) /10; k--; } } for(j=124;j>0;j--) { r1[j]=0; } for(j=124;j>0;j--) { for(i=0;i<125;i++) { r1[j]+=save[i][j]; } r1[j-1]=r1[j]/10; r1[j]=r1[j]%10; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator