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