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:数组非要200才过。。。。。

Posted by cxlm at 2017-12-18 14:46:32 on Problem 1503
In Reply To:数组非要200才过。。。。。 Posted by:268123lry at 2014-12-12 20:07:24
> #include<stdio.h>
> #include<stdlib.h>
> #include<string.h>
> #define max 201
> int turn[max+20]={0};
> int answer[max+20]={0};
>  char number[max+20] ;
> int main()
> {
>     while(1)
>     {
>         scanf("%s",number);
>         if(strcmp(number,"0")==0) break;
>         memset(turn,0,sizeof(turn));
>         int j=0;
>         int length=strlen(number);
>         for(int i=length-1;i>=0;i--)
>         {
>             turn[j]=number[i]-'0';
>             j++;
>         }
>         for(int i=0;i<max;i++)
>         {
>             answer[i]=answer[i]+turn[i];
>             if(answer[i]>=10)
>             {
>                 answer[i]-=10;
>                 answer[i+1]++;
>             }
>         }
>     }
>     bool jump=false;
>     int sum=0;
>     int i;
>     for(i=0;i<max;i++)
>     {
>         sum=answer[i]+sum;
>     }
>     if(sum==0) printf("%d",sum);
>     else
>     {
>        for(int i=max-1;i>=0;i--)
>        {
>           if(jump)
>           {
>              printf("%d",answer[i]);
>           }
>           else if(answer[i])
>           {
>              printf("%d",answer[i]);
>              jump=true;
>           }
>           else continue;
>        }
>     }
>     printf("\n");
>     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