#include <stdio.h>
#include <string.h>
#define N 2004
void Change (char c[],int n[]);
int Sub (int *a,int *b,int lena,int lenb);
int main ()
{
Char X[n],y[n];
int a[n]={0},b[n]={0};
scanf ("%s%s", x, y);
Change (x,a);
Change (Y,B);
int Lena=strlen (x);
int Lenb=strlen (y);
int ans[n]={0};
if (LENA<LENB)
printf ("0\n");
Else
{
int s=sub (A,B,LENA,LENB);
if (s<0)
printf ("0\n");
else if (s==0)
printf ("1\n");
Else
{
int i,j;
Lena=s;
ans[0]++;
int Ntimes=lena-lenb;
for (i=lena;i>=0;i--)
if (i>=ntimes)
B[i]=b[i-ntimes];
Else
b[i]=0;
Lenb=lena;
for (j=0;j<=ntimes;j++)
{
int buffer;
while (1)
{
Buffer=sub (A,B+J,LENA,LENB-J);
if (buffer<0)
Break
ans[ntimes-j]++;
Lena=buffer;
}
}
for (i=0;i<=ntimes;i++)
if (ans[i]>9)
{
ANS[I+1]+=ANS[I]/10;
ans[i]=ans[i]%10;
}
for (i=ntimes;i>=0;i--)
printf ("%d", ans[i]);
printf ("\ n");
}
}
return 0;
}
void Change (char c[],int n[])
{
int i,j=0;
For (I=strlen (c) -1;i>=0;i--)
n[j++]=c[i]-' 0 ';
}
int Sub (int *a,int *b,int lena,int lenb)
{
int i,f=0;
if (LENA<LENB)
return-1;
else if (Lenb==lena)
{
for (i=lena-1;i>=0;i--)
{
if (A[i]<b[i])
return-1;
else if (A[i]>b[i])
Break
}
}
for (i=0;i<lena;i++)
{
A[i]-=b[i];
if (a[i]<0)
{
a[i]+=10;
a[i+1]--;
}
}
for (i=lena-1;i>=0;i--)
{
if (a[i]!=0)
return i+1;
}
return 0;
}
If reproduced, please specify, thank you!
Large integer division, C language Basic syntax implementation