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:我提交了好多次 都是PE 表达错误 但是我实在是不知道错在哪里 请高手看一眼帮帮我

Posted by dangfeng at 2008-11-29 10:46:03 on Problem 1001
In Reply To:我提交了好多次 都是PE 表达错误 但是我实在是不知道错在哪里 请高手看一眼帮帮我 Posted by:qqlook at 2008-11-12 19:05:20
> #define MAX 101
> #include<iostream>
> #include<string>
> #include<string.h>
> #include<stdio.h>
> using namespace std;
> 
> void mul(int a[],int b);
> int Base(string);
> int Point(string);
> void Show(int a[],int);
> int main()
> {
> 	string s;
> 	int n,base,point;
> 	int result[MAX];
> 	while(cin>>s>>n)
> //	s="2.0";n=30;
> 	{
> 		base=Base(s);
> 		point=Point(s);
> 		memset(result,0,sizeof(result));
> 		result[0]=base%10000;
> 		result[1]=base/10000;
> 		for(int i=1;i<n;i++)
> 			mul(result,base);
> 		Show(result,point*n);
> 	}
> 	return 0;
> }
> 
> int Base(string s)
> {
> 	int i;
> 	int n=0;
> 	for(i=0;i<s.length();i++)
> 	{
> 		if(s[i]=='.')continue;
> 		n=n*10+s[i]-'0';
> 	}
> 	for(i=s.length()-1;s[i]=='0';i--)
> 		n/=10;
> 	return n;
> }
> int Point(string s)
> {
> 	int i;
> 	int n=0;
> 	int c=0;
> 	for(i=s.length()-1;s[i]=='0';i--)
> 	{
> 		c++;
> 	}
> 	for(i=s.length()-1;s[i]!='.';i--)
> 	{		
> 		n++;
> 	}
> 	n-=c;
> 	return n;
> }
> 
> void mul(int r[MAX],int b)
> {
> 	int i;
> 	int tmp=0;
> 	for(i=0;i<MAX;i++)
> 	{
> 		tmp=r[i]*b+tmp;
> 		r[i]=tmp%10000;
> 		tmp=tmp/10000;
> 	}
> }
> 
> void Show(int r[MAX],int p)
> {
> 	char s[500];
> 	char s1[500];
> 	int i;
> 	s[0]=s1[0]='\0';
> 	for(i=MAX-1;r[i]==0;i--);
> 	sprintf(s1,"%d",r[i]);
> 	i--;
> 	strcat(s,s1);
> 	for(;i>=0;i--)
> 	{
> 		sprintf(s1,"%04d",r[i]);
> 		strcat(s,s1);
> 	}
> 	if(p==0)
> 		cout<<s<<endl;
> 	else if(p<strlen(s))
> 	{
> 		for(i=0;i<strlen(s)-p;i++)
> 			cout.put(s[i]);
> 		cout<<".";
> 		for(;i<strlen(s);i++)
> 			cout.put(s[i]);
> 	}
> 	else
> 	{
> 		cout<<".";
> 		for(i=0;i<p-strlen(s);i++)
> 		{
> 			cout<<"0";
> 		}
> 		cout<<s;
> 	}
> 	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