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 ls at 2006-04-01 03:28:38 on Problem 1001
In Reply To:哪位大牛能帮我看看 Posted by:ls at 2006-04-01 03:27:48
#include<iostream.h>
void show(int *a)  //输出
{
	int size=a[0],deci=a[size+1];
	int inte=size-deci,i=0;
	if(inte>=0)
	{
		for(i=0;i<inte;i++)
			cout<<a[size-i];
		if(deci!=0)
			cout<<'.';
		for(i=0;i<deci;i++)
			cout<<a[deci-i];
	}
	else
	{
		cout<<'.';
		for(i=0;i<-inte;i++)
			cout<<0;
		for(i=1;i<=size;i++)
			cout<<a[size-i+1];
	}
	cout<<endl;
}

void chen(int *a,int *b,int *cc) 算乘法
{
	int i,j,k;
	int c[1000];
	for(i=0;i<1000;i++)
		c[i]=0;
	for(i=1;i<=b[0];i++)
	{
		k=i;
		for(j=1;j<=a[0];j++)
		{
			c[k]+=b[i]*a[j];
			k++;
		}
	}
	int size=a[0]+b[0];
	int deci=a[a[0]+1]+b[b[0]+1];
	for(i=1;i<=size;i++)
		if(c[i]>=10)
		{
			c[i+1]+=c[i]/10;
			c[i]%=10;
		}
	j=1;
	while(c[j]==0&&j<=deci)
	{
		j++;
		deci--;
		size--;
	}
	i=a[0]+b[0];
	while(c[i]==0)
	{
		size--;
		i--;
	}
	cc[0]=size;
	for(i=1;i<=size;i++)
		cc[i]=c[i+j-1];
	cc[size+1]=deci;
}


void main()
{
	int n,i=0,inter=-1,size=0;
	int result[1000];
	int input[100];
	for(n=0;n<100;n++)
		input[n]=0;
	char a[10];
	do{
		a[i]=cin.get();
		if(a[i]>='0'&&a[i]<='9')
			input[++size]=int(a[i])-int('0');
		else if(a[i]=='.')
			inter=i;
		else
		{
			if(inter==-1)
				inter=i;
			break;
		}
	}while(++i);
	for(i=1;i<=size/2;i++)
	{
		n=input[i];
		input[i]=input[size-i+1];
		input[size-i+1]=n;
	}
	input[0]=size;
	input[size+1]=size-inter;
	for(i=0;i<=size+1;i++)
		result[i]=input[i];
	cin>>n;	
	for(i=1;i<n;i++)
		chen(input,result,result);
	show(result);
}

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