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

帮帮忙啦,为什么出现Compile Error

Posted by 2209080118 at 2010-03-02 15:15:25 on Problem 1001
#include<iostream>
#include<string>
using namespace std;
void daoxu(string &s)
{
	for(int i=0;i<s.size()/2;i++)
	{swap(s[i],s[s.size()-1-i]);
	}
}
void chuliwei(string &s,int k)
{if(k>0)
s.append(k,'0');
else
{
	k=0-k;
	if(s.size()>k)
	s.insert(s.size()-k,".");
	else
	{
		daoxu(s);s.append(k+1-s.size(),'0');
		daoxu(s);s.insert(1,".");
	}
}


}
string chenfa(string s,int k)
{int j=0;char b[1];daoxu(s);

	for(int i=0;i<s.size();i++)
{b[0]=s[i];
	char *a=&b[0];int w;w=atoi(a)*k+j;
	itoa(w%10,&b[0],10);
	j=w/10;
	s[i]=b[0];
	}
if(j!=0)
{itoa(j,&b[0],10);
s.append(1,b[0]);}
daoxu(s);
return s;

}
string jiafa(string s,string p)
{int j=0;char b[1],m[1];daoxu(s);daoxu(p);
if(s.length()>p.length())
swap(s,p);
s.append(p.length()-s.length(),'0');
	for(int i=0;i<s.size();i++)
{b[0]=s[i];m[0]=p[i];
	char *a=&b[0],*g=&m[0];int w;w=atoi(a)+atoi(g);
	itoa((w+j)%10,&b[0],10);
	j=(w+j)/10;
	s[i]=b[0];
	}
if(j!=0)
{itoa(j,&b[0],10);
s.append(1,b[0]);}
daoxu(s);
return s;

}
void quwei(string &s1,string s2,int k,int w)
{s1.assign(s2,k,w);
}
int find(string s)
{
	for(int i=0;i<s.size();i++)
		if(s[i]=='.')
			return i-1;
		return s.size()-1;
		
}
string zucheng(string s1,string s2)
{
string s3("0");
int p1=find(s1);
int p2=find(s2);
if(p1!=s1.size()-1)
s1.erase(p1+1,1);
if(p2!=s2.size()-1)
s2.erase(p2+1,1);
for(int i=0;i<s2.size();i++)
{

		int k;k=i-p2;char b[1];b[0]=s2[i];int w=atoi(&b[0]);

		string ee;
		ee.assign(chenfa(s1,w));	
		ee.append(s2.size()-1-i,'0');	
		s3.assign(jiafa(ee,s3));
		
}
if((s1.size()-p1+s2.size()-2-p2)!=0)
chuliwei(s3,0-(s1.size()-p1+s2.size()-2-p2));
return s3;

}
int main()
{string s;int n,j=0;
string s1,s2,s3,a[100];
char p[100];
s1=p;s2=p;s3=p;
while(cin>>s>>n)
{
quwei(s1,s,0,s.size());
quwei(s2,s,0,s.size());
   for(int i=0;i<n-1;i++)
        s1.assign(zucheng(s1,s2));
		a[j]=s1;j++;
}

for(int i=0;i<j;i++)
{cout<<a[i]<<endl;}
		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