1-6-10: Large integer Addition

Source: Internet
Author: User

Describe

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

The input has two lines, each of which is a non-negative integer that does not exceed 200 bits, and may have extra leading 0. The output line, that 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
1#include <stdio.h>2#include <string.h>3 inta[1001]={0}, b[1001]={0};4 inti, KA, KB, k,c,temp,len;5 Chars[2002],ch;6 voidPlus ()7 {8      for(i =0; I < K; i++)9     {TenA[i] = A[i] + b[i] +C; One         if(a[i]>=Ten) A{a[i]= a[i]%Ten; C=1;}  -         ElseC=0; -     } the     if(c>0) {a[k]=c; k++;} - } - intMain () - { +scanf"%s", s); -k=0; len=strlen (s); +      while(k<len) A     {  ata[k]=s[k]-'0'; -k++; -     } -Ka=K; -scanf"%s", s); -k=0; len=strlen (s); in      while(k<len) -     {  tob[k]=s[k]-'0'; +k++; -     } thekb=K; *     if(Ka >= kb) k =Ka; $     ElsePanax NotoginsengK =kb; -      for(i =0; I < ka/2; i++) the     { +temp=A[i]; Aa[i]=a[ka-i-1];  thea[ka-1-I.] =temp; +     } -      for(i =0; I < kb/2; i++) $     { $temp=B[i]; -b[i]=b[kb-i-1]; -b[kb-1-I.] =temp; the     } -C=0;Wuyi Plus (); the      for(i = k-1; I >=0; i--) -printf"%d", A[i]);  Wu     return 0; -}//only nine of the total.

1-6-10: 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.