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:poj1503测试数据过了,O 开头的也考虑了,为什么还是不过呢???帮忙看看吧

Posted by kumg at 2009-12-08 10:33:25
In Reply To:poj1503测试数据过了,O 开头的也考虑了,为什么还是不过呢???帮忙看看吧 Posted by:Justlikeanddoit at 2009-02-10 00:43:01
> #include<iostream>
> #include<cstring>
> using namespace std;
> void Add(char s1[], char s2[], char result[200])
> {
> char Ans[200];
> char a[101],b[101];
> int i,Len,Len1,Len2,k;
> for (i=0;i<=100;i++)
> 
>     {
> 
>         a[i]=0;
> 
>         b[i]=0;
> 
>         Ans[i]=0;
> 
>     }
> for(i=101;i<200;i++)
>     Ans[i]=0;
> 
>     Len1=strlen(s1);
> 
>     Len2=strlen(s2);
> 
>     if (Len1>Len2) Len=Len1;
> 
>     else Len=Len2;
> 
> 
>     k=0;
> 
>     for (i=Len1-1;i>=0;i--) a[++k]=s1[i]-'0';
> 
>     k=0;
> 
>     for (i=Len2-1;i>=0;i--) b[++k]=s2[i]-'0';
> 
>     for (i=1;i<=Len;i++)
> 
>     {
> 
>         a[i]=a[i]+b[i];
> 
>         if (a[i]>=10)
> 
>         {
> 
>             a[i]=a[i]-10;
> 
>             a[i+1]++;
> 
>         }
> 
>     }
> 
>     while(!a[Len+1])
> 	{
> 		Len--;
> 	}
> 
>     k=0;
> 
>     for (i=Len+1;i>=1;i--) Ans[k++]=a[i]+'0';  
>    strcpy(result, Ans);
> }
> int main()
> {
> 	char str[100];
> 	char sum[200];
> 	memset(sum,0,sizeof(sum));
> 	while(scanf("%s",&str))
> 	{
> 		if(str[0]=='0'&&str[1]=='\0') break;
> 
> 	     Add(sum,str,sum);}
> 	    cout<<sum<<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