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:我也找遍了整个dicuss了,我都通过啦,注意的问题也注意了但是WA了N遍啊大神帮助啊

Posted by mcgrady3 at 2011-11-01 13:15:02 on Problem 1503
In Reply To:我也找遍了整个dicuss了,我都通过啦,注意的问题也注意了但是WA了N遍啊大神帮助啊 Posted by:mcgrady3 at 2011-11-01 13:13:48
> #include <stdio.h>
> #include <string.h>
> #define MAX 300
> int main()
> {
>     int i=0,j,len;
>     char line[MAX];
>     int ans[MAX],com[MAX];
>     memset(ans,0,sizeof(ans));
>     scanf("%s",line);
>     if(line[0]=='0')
>     return 0;
>     for(j=strlen(line)-1;j>=0;j--)    /*i=0是ans的个位,这里是转换*/
>        ans[i++]=(line[j]-'0');
>     while(scanf("%s",line)!=EOF)
>     {
>         if(line[0]=='0')
>         break;
>         j=0;
>         memset(com,0,sizeof(com));
>         for(i=strlen(line)-1;i>=0;i--)
>            com[j++]=(line[i]-'0');
>         i=0;
>            while((ans[i]>=0||com[i]>=0)&&(i<MAX))
>            {
>                if((ans[i]+com[i])>9)
>                {
>                    ans[i]=ans[i]+com[i]-10;
>                    ans[i+1]++;
>                }
>                else
>                ans[i]=ans[i]+com[i];
>                i++;
>            }
>     }
>     bool start=false;
>     for(i=MAX-1;i>=0;i--)
>        if(start)
>         printf("%d",ans[i]);
>        else if(ans[i])
>        {
>            printf("%d",ans[i]);
>            start=true;
>        }
>     return 0;
> }
> 
> 大神帮助啊
编译器用得G++ 或C++都不行

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