C + + General high precision in addition to high precision

Source: Internet
Author: User

Division of codevs3118 High-precision exercises

Played a high-precision in addition to high-precision, a little excitement inside.

Remember when you started to learn it was very difficult to fight

#include <cstdio>
#include <cstring>
Char s1[600],s2[600];
int a1[600],a2[600],a3[600],a4[600],len1,len2,len3,i,j;
int bi (int a3[],int a4[])
{
if (A3[0]<a4[0])
return 0;
if (A3[0]>a4[0])
return 1;
for (int i=a3[0];i>0;i--)
{
if (A3[i]<a4[i])
return 0;
if (A3[i]>a4[i])
return 1;
}
return 1;
}
int jian (int a3[],int a4[])
{
for (int i=1;i<=a3[0];i++)
{
if (A3[i]<a4[i])
{
a3[i]+=10;
a3[i+1]--;
}
A3[i]-=a4[i];
}
for (; a3[a3[0]]==0&&a3[0]>1;a3[0]--);
}
int main ()
{
scanf ("%s", S1);
scanf ("%s", S2);
Len1=strlen (S1);
Len2=strlen (S2);
for (i=0;i<len1;i++)
a1[len1-i]=s1[i]-' 0 ';
for (i=0;i<len2;i++)
a2[len2-i]=s2[i]-' 0 ';
A1[0]=len1;
A2[0]=len2;
a4[0]=a1[0]-a2[0]+1;
for (i=a4[0];i>0;i--)
{
Memset (a3,0,sizeof (A3));
for (j=1;j<=a2[0];j++)
A3[J+I-1]=A2[J];
A3[0]=a2[0]+i-1;
for (; Bi (A1,A3);)
{
a4[i]++;
Jian (A1,A3);
}
}
for (; a4[a4[0]]==0&&a4[0]>1;a4[0]--);
for (i=a4[0];i>0;i--)
printf ("%d", a4[i]);
return 0;
}

C + + General high precision in addition to high precision

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.