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:为什么这程序在VC上可以编译通过且答案正确,而在POJ上却Compile Error?请牛人帮忙!In Reply To:Re:为什么这程序在VC上可以编译通过且答案正确,而在POJ上却Compile Error?请牛人帮忙! Posted by:Fan20091953 at 2010-03-10 17:30:11 帮你把代码该了,可以ac 了 #define N 1000 #include<stdio.h> #include<string.h> int main(){ char str[7]; int n=0; char aResult[N]; int i,j,k,beffect,startcpy; char Cpystr[7]; int mulp1[N]={0},mulp2[N]={0},digitstr[N]={0}; int len=0; int number=0,number1=0; aResult[N-1]='\0'; while(scanf("%s%d",str,&n)!=EOF){ memset(aResult,'0',sizeof(aResult)-1); memset(Cpystr,'0',sizeof(Cpystr)-1); memset(mulp1,0,sizeof(mulp1)-1); memset(mulp2,0,sizeof(mulp2)-1); memset(digitstr,0,sizeof(digitstr)-1); beffect=0; number=0; for(i=0;i<6;i++){ if(beffect && str[i]!='.') Cpystr[number++]=str[i]; else if(str[i]>'0'){ Cpystr[number++]=str[i]; beffect=1; } } for(i=number-1,j=0;i>=0;i--,j++) digitstr[j]=Cpystr[i]-'0'; i=0; while(str[i++]!='.'); len=n*(6-i); for(i=0;i<number;i++) mulp1[i]=digitstr[i]; number1=number; for(i=0;i<n-1;i++){ for(j=0;j<number;j++) for(k=0;k<number1;k++) mulp2[j+k]+=digitstr[j]*mulp1[k]; number1=number1+number; for(j=0;j<=number1;j++) if(mulp2[j]>=10){ mulp2[j+1]+=mulp2[j]/10; mulp2[j]=mulp2[j]%10; } for(j=0;j<=number1;j++) mulp1[j]=mulp2[j]; memset(mulp2,0,sizeof(mulp2)-1); } startcpy=0; for(j=N-2,k=0;j>=0&&k<N;k++){ if(len>=0) len--; if(len==-1 && startcpy==1){ aResult[j--]='.'; k--; len=-2; continue; } if(startcpy==1 ||len==-1) aResult[j--]=mulp1[k]+'0'; else if(mulp1[k]>0){ aResult[j--]=mulp1[k]+'0'; startcpy=1; } } j=0; while(aResult[j++]!='.') if(aResult[j-1]>'0') break; puts(aResult+j-1); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator