A + B problem II---hdu1002

Source: Internet
Author: User

A + B Problem II

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 260647 Accepted Submission (s): 50397

Problem Description

I have a very simple problem for you. Given integers A and B, your job is to calculate the Sum of A + B.

Input

The first line of the input contains an integer T (1<=t<=20) which means the number of test cases. Then T lines follow, each line consists of both positive integers, A and B. Notice that the integers is very large, that M EANs should not process them by using 32-bit integer. Assume the length of each integer would not exceed 1000.

Output

For the test case, you should output of the lines. The first line was "Case #:", # means the number of the the test case. The second line is the equation "A + b = sum", sum means the result of A + B. Note there is some spaces int the Equati On. Output a blank line between the test cases.

Sample Input

2 1 2) 112233445566778899 998877665544332211

Sample Output

Case 1:1 + 2 = 3 Case 2:1.,122,334,455,667,79e,+17 + 998877665544332211 = 1111111111111111110
1#include <stdio.h>2#include <string.h>3 #defineAs 10004 intMain ()5 {6     intas1[ as+ -],as2[ as+ -],cot=0, j,t;7     Charshuru1[ as+ -],shuru2[ as+ -];8     intn,i;9scanf"%d",&n);Ten GetChar ();//absorbing carriage return Onet=N; A      while(n--) -     { -cot++; thescanf"%s", shuru1); -scanf"%s", SHURU2); -memset (AS1,0,sizeof(AS1)); -memset (AS2,0,sizeof(AS2)); +          for(i=0, J=strlen (SHURU1)-1; j>=0; J--, i++) -         { +as1[i]=shuru1[j]-'0'; A              at         } -          for(i=0, J=strlen (SHURU2)-1; j>=0; J--, i++) -         { -as2[i]=shuru2[j]-'0'; -         } -          for(i=0;i< as+ -; i++) in         { -as1[i]+=As2[i]; to             if(as1[i]>=Ten)//To determine whether the full 10 into a +             { -as1[i+1]++; theas1[i]-=Ten; *             } $             Panax Notoginseng         } -          for(i= as+ +;(i>=0) && (as1[i]==0); i--)///Remove the extra 0 in front of the result theprintf"Case %d:\n", cot); +printf"%s +%s =", SHURU1,SHURU2); A          if(i>=0) the          { +               for(; i>=0; i--) -printf"%d", As1[i]); $          } $          Else -printf"0"); -printf"\ n"); the          if(cot!=t) -printf"\ n")///Finally, do not change more linesWuyi     } the     return 0; -}

A + B problem II---hdu1002

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.