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:求救大虾hawk

Posted by frkstyc at 2005-03-29 18:59:30 on Problem 1001
In Reply To:求救大虾hawk Posted by:00448177 at 2005-03-29 18:34:41
> 尊敬的hawk;
> 题干说多余的0可以忽略,所以10.0002结果是1。
> 请看以下我的代码,它是你觉得是数组越界还是栈空间不够。sample是过的.
> #include <iostream.h>
> #include <math.h>
> #include <string.h>
> char d[200];
> char *cheng(char *a,char* b,int i)
> {
> 	char c[200];
> 	for(int m=0;m<199;m++){d[m]='0';c[m]='0';}
> 	d[m]='\0';
> 	c[m]='\0';
> 	int y=0;
> 	for(int x=198;x>i;x--)
> 	{
> 		int carry=0;
> 		for( m=0;m<199;m++)	{c[m]='0';}c[m]='\0';
> 		for(int k=198;k>=0;k--)
> 			{
> 				int s=(a[x]-'0')*(b[k]-'0')+carry;
> 				c[k-y]=s%10+'0';
> 				carry=s/10;
> 			}
> 			y++;
> 		 carry=0;
> 	    for(int v=198;v>=0;v--)
> 		{
> 		    d[v]=(d[v]-'0')+(c[v]-'0')+carry+'0';
> 		   if((d[v]-'0')>9)
> 		   {
> 			  d[v]='0'+(d[v]-'0')%10;
> 			  carry=1;
> 		   }else
> 			carry=0;
> 		}
> 	
> 	  
> 	}
> 	
> 			return d;
> }
> void main()
> {
> 	char a[200],c[200];
> 	for(int m=0;m<199;m++)c[m]='0';c[m]='\0';
> 	int i, n,x,y,v=0;
> 	char b[7];
> 	while(cin>>b)
> 	{
> 		cin>>n;
>         i=198;
> 	for(int j=5;j>=0;j--)
> 	{
> 		if(b[j]!='.')
> 		a[i--]=b[j];
> 		else
> 			y=5-j;
> 
> 	}
> 	x=i;
> 	for(;i>=0;i--)a[i]='0';
> 	a[199]='\0';
> 	strcpy(c,cheng(a,a,x));
> 	for( m=1;m<n-1;m++)
> 	{
> 		strcpy(c,cheng(a,c,x));
> 	}
> 	for(int s=0;c[s]=='0';){s++;}
> 	for(int e=198;c[e]=='0';){e--;}
> 	if(s<199-n*y)v=s;else v=199-n*y;
> 	for( ;v<=e;v++)
> 	{
> 		{if(v==199-n*y)cout<<'.';}
> 		cout<<c[v];
> 	}
> 	cout<<endl;
> 	}
> }
> 	
> 
> 
> 		
> 
> 	
> 
> 
> 
> 
> 
> 			
> 
> 
> 
> 	

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