1-6-11: Large integer Subtraction

Source: Internet
Author: User

Describe

A difference of two large positive integers.

Enter a total of 2 lines, the 1th line is the meiosis A, and the 2nd line is B (a > B). Each large integer does not exceed 200 bits, and there is no redundant leading zeros. The output line, that is, the difference of the request. Sample input

99999999999999999999999999999999999999999999999999

Sample output

9999999999999999999999990000000000000
1#include <stdio.h>2#include <string.h>3 inta[201]={0}, b[201]={0};4 inti, KA, KB, k,c,temp,len;5 Chars[201];6 voidminus ()7 {8      for(i =0; i < ka; i++)9     {Ten         if(A[i] <B[i]) One         {  AC=1;  -a[i+1]--; -         } the     Else -C=0; -A[i] = a[i]+c*Ten-B[i]; -k=Ka; +      while(a[k-1]==0&& k>0) -k--; +     } A } at intMain () - { -scanf"%s", s); -k=0; len=strlen (s); -      while(k<len) -     {  ina[k]=s[k]-'0'; -k++; to     } +Ka=K; -scanf"%s", s); thek=0; len=strlen (s); *      while(k<len) $     { Panax Notoginsengb[k]=s[k]-'0'; -k++; the     } +kb=K; A     if(Ka >= kb) k =Ka; the     Else +K =kb; -      for(i =0; I < ka/2; i++) $     { $temp=A[i]; -a[i]=a[ka-i-1];  -a[ka-1-I.] =temp; the     } -      for(i =0; I < kb/2; i++)Wuyi     { thetemp=B[i]; -b[i]=b[kb-i-1]; Wub[kb-1-I.] =temp; -     } AboutC=0; $ minus (); -      for(i = k-1; I >=0; i--) -printf"%d", A[i]); -     return 0; A}

1-6-11: Large integer Subtraction

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.