Large integer Addition

Source: Internet
Author: User

Total time limit:
1000ms
Memory Limit:
65536kB
Describe

The number of non-negative integers of two not exceeding 200 bits is obtained.

Input
There are two lines, each of which is a non-negative integer that does not exceed 200 bits, and may have extra leading 0.
Output
A row, which is the result after the addition. The result can not have redundant leading 0, that is, if the result is 342, then you cannot output to 0342.
Sample input
2222222222222222222233333333333333333333
Sample output
55555555555555555555
Source
Program Design Internship

The code is actually:

1#include <cstdio>2#include <cstring>3 intLA,LB,LC;4 inta[ About],b[ About],c[ About];5 Charcha[ About],chb[ About];6 intMain () {7scanf"%s%s",&cha,&ChB);8La=strlen (CHA); lb=strlen (CHB);9      for(intI=0; i<la;i++) a[i]=cha[la-i-1]-'0';Ten      for(intI=0; i<lb;i++) b[i]=chb[lb-i-1]-'0'; OneLc=LA; A     if(LB&GT;LC) lc=lb; -      for(intI=0; i<lc;i++){ -c[i]+=a[i]+B[i]; the         if(c[i]>9){ -c[i+1]++; -c[i]%=Ten; -             if(i+1==LC) lc++; +         } -     } +      while(!c[lc]&&lc>0) lc--; A      for(inti=lc;i>=0; i--) printf ("%d", C[i]); atprintf"\ n"); -     return 0; -}

。。。

Large integer Addition

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.