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:哪位大虾指导一下

Posted by frkstyc at 2006-03-21 12:28:04 on Problem 1001
In Reply To:哪位大虾指导一下 Posted by:cpp0600548307 at 2006-03-11 23:39:13
99.998 25
你的程序runtime error

> 代码感觉对,不过DEBURG,检查不出来!哪位能解释一下?
> #include <iostream.h>
> #include <string.h>
> #include <math.h>
> #include <stdio.h>
> 
> char result[200];
> char hold[200];
> void main()
> {
> 	char s[7];
> 	int n,len=0,pointnum=0;
> 	
> 	while(cin>>s>>n){
> 		long num=0;
> 		result[0]='1';
> 
> 		for(int j=0;j<6;j++)
> 			if(s[j]<='9'&&s[j]>='0')
> 			{	
> 				num*=10;
> 			    num+=s[j]-'0';
> 			}
> 		if(s[1]=='0')
> 			pointnum=4;
> 		else
> 			pointnum=3;
> 		pointnum=pow(pointnum,n);
> 	
> 		while(n--){
> 		for(int k=0;k<200;k++)                      //去小数点,按整数值乘法
> 		{
> 			sprintf(hold,"%ld",(result[k]-'0')*num*pow(10,k));
> 			len=strlen(hold);
> 			for(int l=0;l<len;l++)
> 			{
> 				result[l]+=hold[l];
> 			    if(result[l]>9)
> 					result[l+1]++;
> 			}
> 		} 
> 		}
> 		for(int m=199;m>=pointnum;m--)
> 			if(result[m]!=0)
> 				cout<<result[m];
> 			cout<<".";
> 		for(int q=pointnum-1;q>=0;q--)
> 			if(result[q]!=0)
> 				cout<<result[q];
> 	}
> }

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