Large number division (divisor in int range)

Source: Internet
Author: User
#include <iostream> #include <cstdio> #include <cstring> #define N 1000using namespace Std;void Division (Char Bcs[],int Cs,char res[])//divisor is a large number, divisor is int in range {    int i,k,len,t=0,s=0;    BOOL Flag=false;   Whether the quotient has the first effective bit to prevent the business header from appearing 0    Len=strlen (BCS);    for (i=0,k=0; i<len; i++)    {        t=s*10+ (bcs[i]-48);    Xinyu number        if (t/cs>0| | t==0)      //The remainder is 0 to modify the quotient        {            res[k++]=t/cs+48;            S=t%cs;            flag=true;        }        else         //Not enough to remove, modify remainder        {            s=t;            if (flag)   //quotient already has a valid bit, complement 0                res[k++]= ' 0 ';        }    }    for (i=0;i<k;i++)        cout<<res[i];    cout<<endl;    Cout<<s<<endl;} int main () {    char num[n],res[n];    int n;    scanf ("%s%d", num,&n);    Division (num,n,res);    return 0;}

  

Large number division (divisor in int range)

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.