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 |
谁能帮我看看,怎么老是是Runtime Error啊,谢谢了#include <stdio.h> #include <stdlib.h> void mul(char [],int ,char [],int); int main() { char in[6]={0}; char r[100]={0}; unsigned int np; while(EOF!=scanf("%s%d",in,&np)) { int i=5; while(in[i]!='.')i--; int lp = 5 - i; while(i>=1) { in[i] = in[i-1]; i--; } in[i]=48; r[99] = in[5] = in[5]-0x30; r[98] = in[4] = in[4]-0x30; r[97] = in[3] = in[3]-0x30; r[96] = in[2] = in[2]-0x30; r[95] = in[1] = in[1]-0x30; r[94] = in[0] = in[0]-0x30; if(np>1) { int l; for(l=2;l<=np;l++) { mul(r,100,in,6); } } i=0; while(r[i]==0 && i<=99-np*lp)i++; for(;i<=99-np*lp;i++) { printf("%d",r[i]); } if(i<99) { printf("."); int j=99; while(r[j]==0)j--; while(i<=j) { printf("%d",r[i]); i++; } } printf("\n"); //memset(in,0,sizeof(char)*6); //memset(r,0,sizeof(char)*100); for(i=0;i<=5;i++)in[i]=0; for(i=0;i<=99;i++)r[i]=0; } return 0; } void mul(char r[],int rl,char i[],int il) { int c,a; c = 0; //char *m; //m = (char *)malloc(rl*sizeof(char)); //memset(m,0,rl*sizeof(char)); char m[100]={0}; for(int j=il-1,ii=0;j>=0;j--,ii++) { for(int l=rl-1;l>=0;l--) { a = i[j] * r[l]; c = a/10; a = a%10; if(l-ii>=0) { a+=m[l-ii]; m[l-ii]=a%10; } c+=a/10; if(l-ii!=0)m[l-ii-1]+=c; c=0; } } //memcpy(r,m,rl); char x; for(int l=0;l<=99;l++) { x = m[l]; r[l]=x; } //free(m); } 在自己的机器上运行结果是真确的啊? Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator