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 ccgk267 at 2011-10-07 11:32:59 on Problem 3982
In Reply To:那位大牛帮我看看,为啥会不对 Posted by:dxpnb443 at 2011-10-06 22:09:31
> #include<iostream>
> #include<cstring>
> using namespace std;
> int big,d[4][1000],k,m,n,s;
> char a[3][10];
> void add()
> {
>      int p=0;
>      for(int i=0;i<big;i++)
>      {
>              d[s][i]=d[k][i]+d[m][i]+d[n][i]+p;
>              p=d[s][i]/10;
>              if(d[s][i]>9) d[s][i]%=10;
>      }
>      if(p)  {d[s][big]=p;big++;}
> }
> void f()
> { 
>      int len=strlen(a[0]),big=len;
>      for(int i=0;i<len;i++)
>      d[0][i]=a[0][len-i-1]-'0';
>              
>              len=strlen(a[1]);
>              
>              if(big<len) big=len;
>      
>      for(int i=0;i<len;i++)
>      d[1][i]=a[1][len-i-1]-'0';
>      
>      len=strlen(a[2]);
>      
>      if(big<len) big=len;
>      
>      for(int i=0;i<len;i++)
>      d[2][i]=d[2][len-i-1]-'0';
>      
>       for(int i=0;i<97;i++)
>       {
>               k=i%4;
>               m=(i+1)%4;
>               n=(i+2)%4;
>               s=(i+3)%4;
>               add();
>       }
> }
> int main()
> {
>     
>     while(scanf("%s%s%s",&a[0],&a[1],&a[2])!=EOF)
>     {
>            f();
>            for(int i=0;i<big;i++)
>            cout<<d[s][big-i-1];
>            cout<<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