C language High precision subtraction __c language

Source: Internet
Author: User
#include <stdio.h> #include <string.h> int main () {char m[555],n[555];  
    int i,len_m,len_n;  
    int a[555]={0},b[555]={0};  
    scanf ("%s", m);  
    Len_m =strlen (m);  
    for (i=0;i<=len_m-1;i++) a[i]=m[len_m-1-i]-' 0 ';  
    scanf ("%s", n);  
    Len_n=strlen (n);  
    for (i=0;i<=len_n-1;i++) b[i]=n[len_n-1-i]-' 0 ';  
        if (Len_m < Len_n) {printf ("-");  
            for (i=0;i<len_n;i++) {b[i]-=a[i];  
                if (b[i]<0) {b[i]+=10;  
            b[i+1]--;  
        }} i=len_n-1;   
        while (b[i]==0) i--;  
    for (; i>=0;i--) printf ("%d", b[i]);  
            else {for (i=0;i<len_m;i++) {a[i]-=b[i];  
                if (a[i]<0) {a[i]+=10;  
            a[i+1]--; }} i=Len_m-1;   
        while (a[i]==0) i--;  
    for (; i>=0;i--) printf ("%d", a[i]);  
return 0;   }

—————————————————————————————————

This article is original from slience csdn technology blog.

All original articles of this blog please indicate the source in the form of link.

Welcome to this technical blog, this blog article will not be updated regularly.


Most people want to change the world, but few want to reinvent themselves.

There is no desperate situation, only for those in desperate circumstances.

———— by Slience

—————————————————————————————————

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.