版本比较
高精度除法(高&高)
正文
增加 99 行删除 99 行
1234567867891011121314151617181920212223242526272829303132333435363738394010111213141516171819202122232425262728293031323334353637383940414243444546474243444546474849505152535455565758596061626364656667686970717273747576495051525354555657585960616263646566676869707172737475767778798078798081828384858687888990919293949596979899828384858687888990919293949596979899100101102103104105106107108109110101102103104105106107108109110111112
[这个博客已经停止更新,可以到我的个人博客来瞅瞅。](https://blog.owenzjg.com)```cpp#include<bits/stdc++.h> using namespace std; int a[500],b[500],c[500]; #include<bits/stdc++.h>using namespace std;int a[500],b[500],c[500];int compare(int a[],int b[]){ int i; if(a[0]>b[0]) return 1; if(a[0]<b[0]) return -1; for(i=a[0];i>0;i--) { if(a[i]>b[i]) return 1; if(a[i]<b[i]) return -1; } return 0; } void subduction(int a[],int b[]) { int flag; int i; flag=compare(a,b); if(flag==0)//ÏàµÈ { a[0]=0; return; } if(flag==1)//´óÓÚ { for(i=1;i<=a[0];i++) { { int i; if(a[0]>b[0]) return 1; if(a[0]<b[0]) return -1; for(i=a[0];i>0;i--) { if(a[i]>b[i]) return 1; if(a[i]<b[i]) return -1; } return 0;}
void subduction(int a[],int b[]){ int flag; int i;
flag=compare(a,b); if(flag==0)//ÏàµÈ { a[0]=0; return; } if(flag==1)//´óÓÚ { for(i=1;i<=a[0];i++) { if(a[i]<b[i]) { a[i+1]--; a[i]+=10; } a[i]-=b[i]; } { a[i+1]--; a[i]+=10; } a[i]-=b[i]; } while(a[0]>0&&a[a[0]]==0) a[0]--; return; } } int main() { char str1[500],str2[500]; int i,j; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); cin>>str1>>str2; a[0]=strlen(str1); b[0]=strlen(str2); for(i=1;i<=a[0];i++) a[i]=str1[a[0]-i]-'0'; for(i=1;i<=b[0];i++) b[i]=str2[b[0]-i]-'0'; int temp[500]; c[0]=a[0]-b[0]+1; for(i=c[0];i>0;i--) { memset(temp,0,sizeof(temp)); a[0]--; return; }}int main(){ char str1[500],str2[500]; int i,j;
memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c));
cin>>str1>>str2; a[0]=strlen(str1); b[0]=strlen(str2); for(i=1;i<=a[0];i++) a[i]=str1[a[0]-i]-'0'; for(i=1;i<=b[0];i++) b[i]=str2[b[0]-i]-'0';
int temp[500]; c[0]=a[0]-b[0]+1; for(i=c[0];i>0;i--) { memset(temp,0,sizeof(temp));
for(j=1;j<=b[0];j++) temp[j+i-1]=b[j]; temp[0]=b[0]+i-1; temp[j+i-1]=b[j]; temp[0]=b[0]+i-1;
while(compare(a,temp)>=0) { c[i]++; subduction(a,temp); } } while(c[0]>0&&c[c[0]]==0) c[0]--; if(c[0]==0)//Êä³ö½á¹û cout<<0<<endl; else { for(i=c[0];i>0;i--) cout<<c[i]; cout<<endl; } { c[i]++; subduction(a,temp); } }
while(c[0]>0&&c[c[0]]==0) c[0]--;
if(c[0]==0)//Êä³ö½á¹û cout<<0<<endl; else { for(i=c[0];i>0;i--) cout<<c[i]; cout<<endl; }
if(a[0]==0) cout<<0<<endl; else { for(i=a[0];i>0;i--) cout<<a[i]; cout<<endl; } return 0; } cout<<0<<endl; else { for(i=a[0];i>0;i--) cout<<a[i]; cout<<endl; }
return 0;}
```