Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:为什么这程序在VC上可以编译通过且答案正确,而在POJ上却Compile Error?请牛人帮忙!

Posted by Fan20091953 at 2010-03-10 17:30:11 on Problem 1001
In Reply To:为什么这程序在VC上可以编译通过且答案正确,而在POJ上却Compile Error?请牛人帮忙! Posted by:Fan20091953 at 2010-03-09 22:18:54
> #define N 1000
> #include<stdio.h>
> #include<string.h>
> int main(){
> 	char str[7];
> 	int n=0;
> 	char aResult[N];
> 	int i,j,k;
> 	char Cpystr[7];
> 	int mulp1[N]={0},mulp2[N]={0},digitstr[N]={0};
> 	int len=0;
> 	int count=0,count1=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);
> 
> 		bool beffect=false;
> 		count=0;
> 		for(i=0;i<6;i++){
> 			if(beffect&&str[i]!='.')
> 				Cpystr[count++]=str[i];
> 			else if(str[i]>'0'){
> 				Cpystr[count++]=str[i];
> 				beffect=true;
> 			}	
> 		}
> 
> 		for(i=count-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<count;i++)
> 			mulp1[i]=digitstr[i];
> 
> 		count1=count;	
> 		for(i=0;i<n-1;i++){
> 			for(j=0;j<count;j++)
> 				for(k=0;k<count1;k++)
> 					mulp2[j+k]+=digitstr[j]*mulp1[k];
> 
> 			count1=count1+count;
> 			for(j=0;j<=count1;j++)
> 				if(mulp2[j]>=10){
> 					mulp2[j+1]+=mulp2[j]/10;
> 					mulp2[j]=mulp2[j]%10;
> 				}
> 
> 			for(j=0;j<=count1;j++)
> 				mulp1[j]=mulp2[j];
> 
> 			memset(mulp2,0,sizeof(mulp2)-1);
> 		}
> 
> 		bool startcpy=false;
> 		for(j=N-2,k=0;j>=0&&k<N;k++){
> 			if(len>=0) len--;
> 			if(len==-1&&startcpy==true){
> 				aResult[j--]='.';
> 				k--;
> 				len=-2;
> 				continue;
> 			}
> 			if(startcpy==true||len==-1)
> 				aResult[j--]=mulp1[k]+'0';
> 			else if(mulp1[k]>0){
> 				aResult[j--]=mulp1[k]+'0';
> 				startcpy=true;
> 				
> 			}
> 				
> 		}
> 
> 		j=0;
> 		while(aResult[j++]!='.')
> 			if(aResult[j-1]>'0') break;
> 		puts(aResult+j-1);
> 
> 	}
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator