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

哪错了??高手指导一下

Posted by 976423215 at 2011-04-18 22:59:53 on Problem 3982
In Reply To:哪错了?? Posted by:976423215 at 2011-04-18 22:50:12
> #include<iostream>
> #include<string>
> #include<fstream>
> using namespace std;
>  string add(string &s1,string &s2)
>  {
> 	string s3,s="";
> 	int f=0;
> 	int a,b;
> 	char c;int i,k;
> 	if(s2.size ()>s1.size ())
> 	{
> 		s3=s1;
> 		s1=s2;
> 		s2=s3;
> 	}
> 	for(i=s2.size ()-1,k=s1.size ()-1;i>=0;i--,k--)
> 	{
> 		a=s1[k]-'0';
> 		b=s2[i]-'0';
> 		if(a+b+f>=10)
> 		{
> 			c=a+b+f-10+'0';
> 			s=c+s;
> 			f=1;
> 		}
> 		else
> 		{
> 			c=a+b+f+'0';
> 			s=c+s;
> 			f=0;
> 		}
> 	}
> 	for(;k>=0;k--)
> 	{
> 		a=s1[k]-'0';
> 		if(a+f>=10)
> 		{
> 			c=a+f-10+'0';
> 			s=c+s;
> 			f=1;
> 		}
> 		else
> 		{
> 			c=a+f+'0';
> 			s=c+s;
> 			f=0;
> 		}
> 	}
> 	if(f==1)
> 	{
> 		c=f+'0';
> 		s=c+s;
> 	}
> 	return s;
> }
> int main()
> {
> 		string s[100];
> 	while(cin>>s[0]>>s[1]>>s[2])
> 	{
> 		for(int i=3;i<=99;i++)
> 		{
> 			s[i]=add(s[i-1],s[i-2]);
> 			s[i]=add(s[i],s[i-3]);
> 		}
> 		cout<<s[99]<<endl;
> 	}
> 	system("pause");
> 	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