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:一次AC,上代码

Posted by 110831115 at 2010-06-21 10:38:16 on Problem 1000
In Reply To:Re:一次AC,上代码 Posted by:hero19930 at 2010-06-19 10:29:17
> #include <stdio.h>
> #include <string.h>
> 
> void Add(char a[], char b[], char c[])
> {
>      int len;
>      int i, x = 0;
>      if(a[0] > b[0])
>          len = a[0];
>      else 
>          len = b[0];
>      for(i = 1; i <= len; i++)
>      {
>          x = x / 10 + a[i] + b[i];
>          c[i] = x % 10;
>      }
>      c[i] = x / 10;
>      c[0] = i;
>      while(c[c[0]] == 0 && c[0] > 0)
>          c[0]--;
> }
> 
> int main()
> {
>     char a[100], b[100], c[100], t[100];
>     int i;
>     for(i = 0; i < 100; i++)
>         a[i] = b[i] = c[i] = t[i] = 0;
>     scanf("%s", t);
>     a[0] = strlen(t);
>     for(i = 1; i <= a[0]; i++)
>         a[i] = t[a[0] - i] - '0';
>     scanf("%s", t);
>     b[0] = strlen(t);
>     for(i = 1; i <= b[0]; i++)
>         b[i] = t[b[0] - i] - '0';
>     Add(a, b, c);
>     for(i = c[0]; i >= 1; i--)
>         printf("%d", c[i]);
>     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