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:为什么老是runtime error,本地运行正确啊!!!

Posted by love1390251 at 2012-04-03 17:49:47 on Problem 1001
In Reply To:为什么老是runtime error,本地运行正确啊!!! Posted by:shanjiaoxiaread at 2012-03-28 11:16:51
> #include<stdio.h>
> #include<string.h>
> #include<stdlib.h>
> char result[161];
> char R[161];
> void  mypower(char * R,char* R2,char * result){
>   char src[161];
>   char mid[161];
>   char midAdd[161];
>   int  midAddIndex,midIndex,rigStartAdd;
>   int rigStart=sizeof(src)-1;
>   int i=0,temp=0,digit=0,length,length2,j;
>   
>   midAddIndex=midIndex=rigStartAdd=sizeof(src)-1;
>   strcpy(src,R);
>   length=strlen(src);
>   length2=strlen(R2);
>   for( j=0;j<sizeof(src)-1;j++){
>    mid[j]='0';
>   }
>   mid[midIndex]='\0';
>   for(i=length-1;i>=0;i--){
> 	  if(src[i]=='.')
> 		  continue;
> 	  rigStartAdd--;
> 	  midIndex=rigStartAdd;
> 	  for( j=0;j<sizeof(src)-1;j++){
> 		 midAdd[j]='0';
> 		}
> 	  midAddIndex=sizeof(src)-1;
> 	  midAdd[midAddIndex--]='\0';
> 	  temp=0;
> 	  for(j=length2-1;j>=0;j--){
> 		  if(R2[j]=='.')
> 		    continue;
> 	      digit=(src[i]-'0')*(R2[j]-'0'); 
> 		  digit=digit+temp;
>           midAdd[midAddIndex--]=digit%10+'0';
> 		  temp=digit/10;
> 	  }
> 	  midAdd[midAddIndex]=temp+'0';
> 	  temp=0;
> 	  for(j=sizeof(mid)-2;j>=0;j--){
> 	     temp=mid[midIndex]-'0'+midAdd[j]-'0'+temp;
> 		 mid[midIndex--]=temp%10+'0';
> 		 temp=temp/10;
> 	  }
> 	  mid[midIndex]=temp+'0';
>   }
>   
>   i=0;
>   while(result[i]=mid[i])
> 	  i++;
>  
> }
> int decimalNum(int n){
>  int m=0;
>  char * p=R;
>  while(*p!='\0'&&*p!='.'&&m<sizeof(R)){
> 	 p++;
> 	 m++;
>  }
>  if(*p=='\0')
> 	 return 0;
>  return (n*(strlen(R)-m-1));                                                                                    
> }
> void bigIntMulti(char *R,char re[5][161],int n){
> 	int number;
> 	int i,m,start,end,j;
> 	number=decimalNum(n);
> 	if((n%2)==1)
> 	    mypower(result,re[0],result);
> 	n=n/2;
> 	for( i=0;i<4;i++){
> 		mypower(R,R,re[i+1]);
> 		if((n%2)==1){
> 		  mypower(result,re[i+1],result);
> 		}
>         n=n/2;		
> 		strcpy(R,re[i+1]);
> 	}
>     end=sizeof(result)-2;
>     m=end-number;
>     for(start=0;result[start]=='0';start++);
> 	for(i=0,j=start;j<=m;i++,j++){
> 	   result[i]=result[j];
> 	}
> 	if(number>0)
> 	   result[i++]='.';
> 	if(m<start)
> 		j=m+1;
> 	for(;j<=end;i++,j++){
> 	   result[i]=result[j];
> 	}
> 	
> 	while(result[i]=='0'||result[i]=='.')
> 		i--;
>     result[i+1]='\0';
>     printf("%s\n",result);  
> 	
> }
> int main(){
> 	
> 	char input[100][10];
> 	int  inputN[100];
> 	char re[5][161];
>     int i=0,j;
> 	double temp;
> 	while(scanf("%s %d",input[i],&inputN[i])==2&&i<100)
> 		i++;
> 	for( j=0;j<i;j++){
>          temp=(double)strtod(input[j],NULL);
> 		if(  ( temp>=99.999) ||(temp<=0.0) ){
> 	     	continue;
> 		}
> 		if((inputN[j]<=0)||(inputN[j]>25)){
> 			continue;
> 		}
> 		
> 		
> 	result[0]='1';
> 	result[1]='\0';
> 	strcpy(R,input[j]);
> 	strcpy(re[0],R);
>     bigIntMulti(R,re,inputN[j]);
> 	}  
> 	
>    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